Terry J. Reedy <tjre...@udel.edu> added the comment:
1. NO SKIP utest.py with debug prints added and @skipIf initially commented out. --- from unittest import TestCase, skipIf #@skipIf(True, "Skip Testing") class Tests(TestCase): def test_skip(self): "this test will fail - if not skipped" print('asserting') self.assertEqual(0, 1) print(Tests("test_skip").run()) print(Tests("test_skip").debug()) --- test_skip is run twice, with the output difference being as documented. asserting <unittest.result.TestResult run=1 errors=0 failures=1> asserting Traceback (most recent call last): ... AssertionError: 0 != 1 2. SKIPTEST Adding "self.skipTest('why')" either in a new setUp() or at the top of skip_test() and adding another print print(Tests("test_skip").run().skipped) results in the output I expect from the doc. <unittest.result.TestResult run=1 errors=0 failures=0> [(<__main__.Tests testMethod=test_skip>, 'why')] Traceback (most recent call last): ... unittest.case.SkipTest: why 3. SKIPIF CLASS Uncommenting @skipIf (the OP's case) instead results in None asserting Traceback ... AssertionError: 0 != 1 Since .run does not run the test, I agree that debug() running the test and raising AssertionError is a bug. The test should not be run. In my original comments, I expected SkipTest, as in cases 2 above and 4 below. I have not yet checked the current tests. 4. SKIPIF FUNC Moving the skipIf decorator to test_skip results in None Traceback (most recent call last): .. unittest.case.SkipTest: Skip Testing I don't know why run() returns None for skipIf cases instead of returning a TestResult with non-empty skipped, as it does for skipTest, or if the None is a separate bug. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36674> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com