diff options
author | Stefano Rivera <stefano@rivera.za.net> | 2023-04-27 01:28:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 01:28:46 (GMT) |
commit | 76632b836cf81a95301f4eb1fa43682e8d9ffa67 (patch) | |
tree | e34dfe04b641f614b06423ff7abd853d765e452d /Lib/test/test_unittest/test_runner.py | |
parent | dc3f97549a8fe4f7fea8d0326e394760b51caa6e (diff) | |
download | cpython-76632b836cf81a95301f4eb1fa43682e8d9ffa67.zip cpython-76632b836cf81a95301f4eb1fa43682e8d9ffa67.tar.gz cpython-76632b836cf81a95301f4eb1fa43682e8d9ffa67.tar.bz2 |
gh-62432: unittest runner: Exit code 5 if no tests were run (#102051)
As discussed in https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498/7
It is common for test runner misconfiguration to fail to find any tests,
This should be an error.
Fixes: #62432
Diffstat (limited to 'Lib/test/test_unittest/test_runner.py')
-rw-r--r-- | Lib/test/test_unittest/test_runner.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_unittest/test_runner.py b/Lib/test/test_unittest/test_runner.py index ceb4c8a..f3b2c0c 100644 --- a/Lib/test/test_unittest/test_runner.py +++ b/Lib/test/test_unittest/test_runner.py @@ -577,6 +577,16 @@ class TestClassCleanup(unittest.TestCase): 'inner setup', 'inner test', 'inner cleanup', 'end outer test', 'outer cleanup']) + def test_run_empty_suite_error_message(self): + class EmptyTest(unittest.TestCase): + pass + + suite = unittest.defaultTestLoader.loadTestsFromTestCase(EmptyTest) + runner = getRunner() + runner.run(suite) + + self.assertIn("\nNO TESTS RAN\n", runner.stream.getvalue()) + class TestModuleCleanUp(unittest.TestCase): def test_add_and_do_ModuleCleanup(self): |