Skip to content

Commit 34b7c43

Browse files
authored
bpo-34279: regrtest consider that skipped tests are ran (GH-11132) (GH-11158)
bpo-34279, bpo-35412: support.run_unittest() no longer raises TestDidNotRun if a test result contains skipped tests. The exception is now only raised if no test have been run and no test have been skipped. (cherry picked from commit 3a8f4fe)
1 parent 16d6320 commit 34b7c43

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ def _run_suite(suite):
15431543
runner = BasicTestRunner()
15441544

15451545
result = runner.run(suite)
1546-
if not result.testsRun:
1546+
if not result.testsRun and not result.skipped:
15471547
raise TestDidNotRun
15481548
if not result.wasSuccessful():
15491549
if len(result.errors) == 1 and not result.failures:

Lib/test/test_regrtest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,19 @@ def test_main():
734734
output = self.run_tests("-m", "nosuchtest", testname, exitcode=0)
735735
self.check_executed_tests(output, [testname], no_test_ran=testname)
736736

737+
def test_no_tests_ran_skip(self):
738+
code = textwrap.dedent("""
739+
import unittest
740+
741+
class Tests(unittest.TestCase):
742+
def test_skipped(self):
743+
self.skipTest("because")
744+
""")
745+
testname = self.create_test(code=code)
746+
747+
output = self.run_tests(testname, exitcode=0)
748+
self.check_executed_tests(output, [testname])
749+
737750
def test_no_tests_ran_multiple_tests_nonexistent(self):
738751
code = textwrap.dedent("""
739752
import unittest
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:func:`test.support.run_unittest` no longer raise :exc:`TestDidNotRun` if
2+
the test result contains skipped tests. The exception is now only raised if
3+
no test have been run and no test have been skipped.

0 commit comments

Comments
 (0)