Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a8f4fe

Browse files
authored
bpo-34279: regrtest consider that skipped tests are ran (GH-11132)
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.
1 parent 7acd50a commit 3a8f4fe

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ def _run_suite(suite):
19371937
if junit_xml_list is not None:
19381938
junit_xml_list.append(result.get_xml_element())
19391939

1940-
if not result.testsRun:
1940+
if not result.testsRun and not result.skipped:
19411941
raise TestDidNotRun
19421942
if not result.wasSuccessful():
19431943
if len(result.errors) == 1 and not result.failures:

Lib/test/test_regrtest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ def test_bug(self):
10041004
output = self.run_tests("-w", testname, exitcode=2)
10051005
self.check_executed_tests(output, [testname],
10061006
failed=testname, rerun=testname)
1007+
10071008
def test_no_tests_ran(self):
10081009
code = textwrap.dedent("""
10091010
import unittest
@@ -1017,6 +1018,19 @@ def test_bug(self):
10171018
output = self.run_tests(testname, "-m", "nosuchtest", exitcode=0)
10181019
self.check_executed_tests(output, [testname], no_test_ran=testname)
10191020

1021+
def test_no_tests_ran_skip(self):
1022+
code = textwrap.dedent("""
1023+
import unittest
1024+
1025+
class Tests(unittest.TestCase):
1026+
def test_skipped(self):
1027+
self.skipTest("because")
1028+
""")
1029+
testname = self.create_test(code=code)
1030+
1031+
output = self.run_tests(testname, exitcode=0)
1032+
self.check_executed_tests(output, [testname])
1033+
10201034
def test_no_tests_ran_multiple_tests_nonexistent(self):
10211035
code = textwrap.dedent("""
10221036
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)