diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-09-07 19:10:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 19:10:19 (GMT) |
commit | e46be0d2fa18d7e3435c3b19370604043b1f8cf0 (patch) | |
tree | c926dcef62493d409d4d3ab3f23d19aa0692573e | |
parent | c2b8d4fe0d785358902487fb8abcb81351da1b90 (diff) | |
download | cpython-e46be0d2fa18d7e3435c3b19370604043b1f8cf0.zip cpython-e46be0d2fa18d7e3435c3b19370604043b1f8cf0.tar.gz cpython-e46be0d2fa18d7e3435c3b19370604043b1f8cf0.tar.bz2 |
[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 7e1a7abb9831965cdec477e62dbe4f8415b8a582)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-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 94b3143..8be89eb 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -362,9 +362,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) |