]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-68403: Fix test_coverage in test_trace (GH-108910)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 7 Sep 2023 18:28:18 +0000 (21:28 +0300)
committerGitHub <noreply@github.com>
Thu, 7 Sep 2023 18:28:18 +0000 (21:28 +0300)
Its behavior no longer affected by test running options such as -m.

Lib/test/test_trace.py

index d1ef005a4314ed28565514042b563b8388c6d538..c1e289bcaff9e5e24874d3aad56c18323bb00bcb 100644 (file)
@@ -360,9 +360,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)