]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-68403: Fix test_coverage in test_trace (GH-108910) (GH-109105)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 7 Sep 2023 19:10:19 +0000 (12:10 -0700)
committerGitHub <noreply@github.com>
Thu, 7 Sep 2023 19:10:19 +0000 (19:10 +0000)
Its behavior no longer affected by test running options such as -m.
(cherry picked from commit 7e1a7abb9831965cdec477e62dbe4f8415b8a582)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_trace.py

index 94b314381bfe21c5e64044855c50c66a5b998945..8be89eb0245bb74194ad4e5986158ddad3007a04 100644 (file)
@@ -362,9 +362,14 @@ class TestCoverage(unittest.TestCase):
         rmtree(TESTFN)
         unlink(TESTFN)
 
-    def _coverage(self, tracer,
-                  cmd='import test.support, test.test_pprint;'
-                      'test.support.run_unittest(test.test_pprint.QueryTestCase)'):
+    DEFAULT_SCRIPT = '''if True:
+        import unittest
+        from test.test_pprint import QueryTestCase
+        loader = unittest.TestLoader()
+        tests = loader.loadTestsFromTestCase(QueryTestCase)
+        tests(unittest.TestResult())
+        '''
+    def _coverage(self, tracer, cmd=DEFAULT_SCRIPT):
         tracer.run(cmd)
         r = tracer.results()
         r.write_results(show_missing=True, summary=True, coverdir=TESTFN)