Skip to content

Commit e46be0d

Browse files
[3.11] gh-68403: Fix test_coverage in test_trace (GH-108910) (GH-109105)
Its behavior no longer affected by test running options such as -m. (cherry picked from commit 7e1a7ab) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent c2b8d4f commit e46be0d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/test/test_trace.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,14 @@ def tearDown(self):
362362
rmtree(TESTFN)
363363
unlink(TESTFN)
364364

365-
def _coverage(self, tracer,
366-
cmd='import test.support, test.test_pprint;'
367-
'test.support.run_unittest(test.test_pprint.QueryTestCase)'):
365+
DEFAULT_SCRIPT = '''if True:
366+
import unittest
367+
from test.test_pprint import QueryTestCase
368+
loader = unittest.TestLoader()
369+
tests = loader.loadTestsFromTestCase(QueryTestCase)
370+
tests(unittest.TestResult())
371+
'''
372+
def _coverage(self, tracer, cmd=DEFAULT_SCRIPT):
368373
tracer.run(cmd)
369374
r = tracer.results()
370375
r.write_results(show_missing=True, summary=True, coverdir=TESTFN)

0 commit comments

Comments
 (0)