Commit 34b7c438 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

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 3a8f4fef)
parent 16d63202
...@@ -1543,7 +1543,7 @@ def _run_suite(suite): ...@@ -1543,7 +1543,7 @@ def _run_suite(suite):
runner = BasicTestRunner() runner = BasicTestRunner()
result = runner.run(suite) result = runner.run(suite)
if not result.testsRun: if not result.testsRun and not result.skipped:
raise TestDidNotRun raise TestDidNotRun
if not result.wasSuccessful(): if not result.wasSuccessful():
if len(result.errors) == 1 and not result.failures: if len(result.errors) == 1 and not result.failures:
......
...@@ -734,6 +734,19 @@ class ArgsTestCase(BaseTestCase): ...@@ -734,6 +734,19 @@ class ArgsTestCase(BaseTestCase):
output = self.run_tests("-m", "nosuchtest", testname, exitcode=0) output = self.run_tests("-m", "nosuchtest", testname, exitcode=0)
self.check_executed_tests(output, [testname], no_test_ran=testname) self.check_executed_tests(output, [testname], no_test_ran=testname)
def test_no_tests_ran_skip(self):
code = textwrap.dedent("""
import unittest
class Tests(unittest.TestCase):
def test_skipped(self):
self.skipTest("because")
""")
testname = self.create_test(code=code)
output = self.run_tests(testname, exitcode=0)
self.check_executed_tests(output, [testname])
def test_no_tests_ran_multiple_tests_nonexistent(self): def test_no_tests_ran_multiple_tests_nonexistent(self):
code = textwrap.dedent(""" code = textwrap.dedent("""
import unittest import unittest
......
:func:`test.support.run_unittest` no longer raise :exc:`TestDidNotRun` if
the test result contains skipped tests. The exception is now only raised if
no test have been run and no test have been skipped.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment