]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34279: regrtest consider that skipped tests are ran (GH-11132)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 14 Dec 2018 12:26:58 +0000 (04:26 -0800)
committerGitHub <noreply@github.com>
Fri, 14 Dec 2018 12:26:58 +0000 (04:26 -0800)
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)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
Lib/test/support/__init__.py
Lib/test/test_regrtest.py
Misc/NEWS.d/next/Tests/2018-12-12-18-20-18.bpo-34279.DhKcuP.rst [new file with mode: 0644]

index 512e354fabc89f36622ebcc041daa39323b035ed..5bea5474f2829782dc438ff7c1f6275aba9af6ed 100644 (file)
@@ -1897,7 +1897,7 @@ def _run_suite(suite):
     if junit_xml_list is not None:
         junit_xml_list.append(result.get_xml_element())
 
-    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:
index db9bd6dfc04359179cd23ebfa029ec06d9d207c1..a67458313addb2b5999afc35c6ec7325c5bfbe82 100644 (file)
@@ -1004,6 +1004,7 @@ class ArgsTestCase(BaseTestCase):
         output = self.run_tests("-w", testname, exitcode=2)
         self.check_executed_tests(output, [testname],
                                   failed=testname, rerun=testname)
+
     def test_no_tests_ran(self):
         code = textwrap.dedent("""
             import unittest
@@ -1017,6 +1018,19 @@ class ArgsTestCase(BaseTestCase):
         output = self.run_tests(testname, "-m", "nosuchtest", 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 (file)
index 0000000..5a70cc5
--- /dev/null
@@ -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.