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
This commit is contained in:
Stefano Rivera 2023-04-26 18:28:46 -07:00 committed by GitHub
parent dc3f97549a
commit 76632b836c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 64 additions and 22 deletions

View file

@ -274,6 +274,8 @@ class TextTestRunner(object):
infos.append("failures=%d" % failed)
if errored:
infos.append("errors=%d" % errored)
elif run == 0:
self.stream.write("NO TESTS RAN")
else:
self.stream.write("OK")
if skipped: