Skip to content

Commit 3896096

Browse files
committed
unittest: Exit with non-zero code on failures.
`unittest.main()` will now cause the process to exit with a non-zero status code on test failure. This behaviour is assumed by the test framework used in this repo (in `tools/ci.sh`), is what happens when using the unittest-discover module, and is what CPython does. Removing `unittest/tests/exception.py` as this test always fails (by design). This functionality (a bare function being used as a test raises an error that is not a subclass of `AssertionError`) had a test added in the previous commit (`test_basics.Basics.test_bare_function__error`). Signed-off-by: Greg Darke <micropython@me.tsukasa.au>
1 parent 0120d94 commit 3896096

3 files changed

Lines changed: 4 additions & 17 deletions

File tree

python-stdlib/unittest/tests/exception.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

python-stdlib/unittest/unittest/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,7 @@ def main(module="__main__", testRunner=None):
593593
module = __import__(module)
594594
suite = TestSuite(module.__name__)
595595
suite._load_module(module)
596-
return testRunner.run(suite)
596+
result = testRunner.run(suite)
597+
if not result.wasSuccessful():
598+
sys.exit(result.failuresNum + result.errorsNum)
599+
return result

tools/ci.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function ci_package_tests_run {
6363
python-stdlib/os-path/test_path.py \
6464
python-stdlib/pickle/test_pickle.py \
6565
python-stdlib/string/test_translate.py \
66-
python-stdlib/unittest/tests/exception.py \
6766
unix-ffi/gettext/test_gettext.py \
6867
unix-ffi/pwd/test_getpwnam.py \
6968
unix-ffi/re/test_re.py \

0 commit comments

Comments
 (0)