diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-07 18:28:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 18:28:18 (GMT) |
commit | 7e1a7abb9831965cdec477e62dbe4f8415b8a582 (patch) | |
tree | e157f2d1204571dc862739bc7ed9ced382866414 | |
parent | 1829a3c9a3712b6a68a3a449e4a08787c73da51d (diff) | |
download | cpython-7e1a7abb9831965cdec477e62dbe4f8415b8a582.zip cpython-7e1a7abb9831965cdec477e62dbe4f8415b8a582.tar.gz cpython-7e1a7abb9831965cdec477e62dbe4f8415b8a582.tar.bz2 |
gh-68403: Fix test_coverage in test_trace (GH-108910)
Its behavior no longer affected by test running options such as -m.
-rw-r--r-- | Lib/test/test_trace.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index d1ef005..c1e289b 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -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) |