summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unittest/test_runner.py
diff options
context:
space:
mode:
authorStefano Rivera <stefano@rivera.za.net>2023-04-27 01:28:46 (GMT)
committerGitHub <noreply@github.com>2023-04-27 01:28:46 (GMT)
commit76632b836cf81a95301f4eb1fa43682e8d9ffa67 (patch)
treee34dfe04b641f614b06423ff7abd853d765e452d /Lib/test/test_unittest/test_runner.py
parentdc3f97549a8fe4f7fea8d0326e394760b51caa6e (diff)
downloadcpython-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.py10
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):