From a0d4aac5cdfbe7c7a650681c4130f980731dc891 Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Tue, 4 Aug 2020 19:50:33 +0000 Subject: [PATCH] Test that we can output a valid test directory. --- tests/data/nest/less/why.md | 11 +++++++++++ tests/data/nest/more/why.md | 6 +++++- tests/test.py | 9 +++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/data/nest/less/why.md diff --git a/tests/data/nest/less/why.md b/tests/data/nest/less/why.md new file mode 100644 index 0000000..d8bb6cc --- /dev/null +++ b/tests/data/nest/less/why.md @@ -0,0 +1,11 @@ +# why? + +Tests need to work even when the same filename is in multiple directories. + +```py +import unittest + +class TestLess(unittest.TestCase): + def test_less(self): + self.assertTrue(True) +``` diff --git a/tests/data/nest/more/why.md b/tests/data/nest/more/why.md index fe03402..ff50e89 100644 --- a/tests/data/nest/more/why.md +++ b/tests/data/nest/more/why.md @@ -3,7 +3,11 @@ We want to make sure that in more complext documentation structures, which may have multiple sub directories, we are still formatting name and paths correctly. ```py -print("oh that makes sense") +import unittest + +class TestMore(unittest.TestCase): + def test_more(self): + self.assertTrue(True) ``` Good. diff --git a/tests/test.py b/tests/test.py index 83563cf..8b6ba0f 100644 --- a/tests/test.py +++ b/tests/test.py @@ -2,6 +2,7 @@ import shutil import textwrap import unittest +import subprocess import click.testing @@ -130,6 +131,14 @@ def test_prefixed_deep_blocks(self): self.assertTrue(self._output_path_exists('test_other.py')) self.assertTrue(self._output_path_exists('nest/test_deep.py')) self.assertTrue(self._output_path_exists('nest/more/test_why.py')) + self.assertTrue(self._output_path_exists('nest/less/test_why.py')) + + # Check that mkcodes can actually output a valid test directory. + proc = subprocess.run( + ['python3', '-m', 'unittest', 'discover', 'tests/output'], + capture_output=True, text=True) + self.assertIn('Ran 2 tests', proc.stderr) + self.assertIn('OK', proc.stderr) @unittest.skip def test_glob(self):