summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-12-14 13:44:08 +0100
committerGitHub <noreply@github.com>2018-12-14 13:44:08 +0100
commit34b7c438b8dc0a1e7e23c9b2d7ce7f8a7c31b4f4 (patch)
tree88bdc9e2ebe4aa64850d57f5c31947b8dcecee73
parent16d63202af35dadd652a5e3eae687ea709e95b11 (diff)
downloadcpython-git-34b7c438b8dc0a1e7e23c9b2d7ce7f8a7c31b4f4.tar.gz
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 3a8f4fef4a4dd0e4a800545468eef9542e126181)
-rw-r--r--Lib/test/support/__init__.py2
-rw-r--r--Lib/test/test_regrtest.py13
-rw-r--r--Misc/NEWS.d/next/Tests/2018-12-12-18-20-18.bpo-34279.DhKcuP.rst3
3 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index aaf028632a..9effdddd27 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1543,7 +1543,7 @@ def _run_suite(suite):
runner = BasicTestRunner()
result = runner.run(suite)
- if not result.testsRun:
+ if not result.testsRun and not result.skipped:
raise TestDidNotRun
if not result.wasSuccessful():
if len(result.errors) == 1 and not result.failures:
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 015adc3fa0..872ba64611 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -734,6 +734,19 @@ class ArgsTestCase(BaseTestCase):
output = self.run_tests("-m", "nosuchtest", testname, exitcode=0)
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):
code = textwrap.dedent("""
import unittest
diff --git a/Misc/NEWS.d/next/Tests/2018-12-12-18-20-18.bpo-34279.DhKcuP.rst b/Misc/NEWS.d/next/Tests/2018-12-12-18-20-18.bpo-34279.DhKcuP.rst
new file mode 100644
index 0000000000..5a70cc5308
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-12-12-18-20-18.bpo-34279.DhKcuP.rst
@@ -0,0 +1,3 @@
+: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.