diff options
| author | Preston Timmons <prestontimmons@gmail.com> | 2013-12-16 10:04:28 -0600 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-12-26 11:26:24 -0500 |
| commit | aef019de6113e6c750e3ba49dc1e9f2a179eb0ca (patch) | |
| tree | 57b1f1c51e4651fb465d64e883943fd03ce5275b /tests | |
| parent | 52325b0a04cf1fcf444cece197585a35cf65bab9 (diff) | |
Fixed #21206 -- No longer run discovery if the test label doesn't point to a package or directory.
Thanks thepapermen for the report and Carl Meyer for the review.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_discovery_sample/empty.py | 0 | ||||
| -rw-r--r-- | tests/test_discovery_sample/tests_sample.py | 4 | ||||
| -rw-r--r-- | tests/test_runner/test_discover_runner.py | 28 |
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_discovery_sample/empty.py b/tests/test_discovery_sample/empty.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/test_discovery_sample/empty.py diff --git a/tests/test_discovery_sample/tests_sample.py b/tests/test_discovery_sample/tests_sample.py index fb1e14c715..d538771b0f 100644 --- a/tests/test_discovery_sample/tests_sample.py +++ b/tests/test_discovery_sample/tests_sample.py @@ -13,3 +13,7 @@ class TestDjangoTestCase(DjangoTestCase): def test_sample(self): self.assertEqual(1, 1) + + +class EmptyTestCase(TestCase): + pass diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py index d577f26826..fd68949678 100644 --- a/tests/test_runner/test_discover_runner.py +++ b/tests/test_runner/test_discover_runner.py @@ -68,6 +68,34 @@ class DiscoverRunnerTest(TestCase): self.assertEqual(count, 3) + def test_empty_test_case(self): + count = DiscoverRunner().build_suite( + ["test_discovery_sample.tests_sample.EmptyTestCase"], + ).countTestCases() + + self.assertEqual(count, 0) + + def test_discovery_on_package(self): + count = DiscoverRunner().build_suite( + ["test_discovery_sample.tests"], + ).countTestCases() + + self.assertEqual(count, 1) + + def test_ignore_adjacent(self): + """ + When given a dotted path to a module, unittest discovery searches + not just the module, but also the directory containing the module. + + This results in tests from adjacent modules being run when they + should not. The discover runner avoids this behavior. + """ + count = DiscoverRunner().build_suite( + ["test_discovery_sample.empty"], + ).countTestCases() + + self.assertEqual(count, 0) + def test_overrideable_test_suite(self): self.assertEqual(DiscoverRunner().test_suite, TestSuite) |
