Skip to content

Commit 68ba35e

Browse files
[3.12] gh-68403: Fix test_coverage in test_trace (GH-108910) (#109104)
gh-68403: Fix test_coverage in test_trace (GH-108910) 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 41ff5b0 commit 68ba35e

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
@@ -360,9 +360,14 @@ def tearDown(self):
360360
rmtree(TESTFN)
361361
unlink(TESTFN)
362362

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

0 commit comments

Comments
 (0)