[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 7e1a7abb98)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-09-07 12:10:19 -07:00 committed by GitHub
parent c2b8d4fe0d
commit e46be0d2fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -362,9 +362,14 @@ def tearDown(self):
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)