summaryrefslogtreecommitdiff
path: root/tests/coveragetest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-13 06:47:57 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-13 07:46:16 -0400
commit001f6532f8a8bf05f1cf6f2b5574ba091550a77d (patch)
tree4beb1d4bf18483b4f95d245c5f410a9d23bb0c61 /tests/coveragetest.py
parentd137a41da2f1a7010a1bd4305962670af2f7dae1 (diff)
downloadpython-coveragepy-git-001f6532f8a8bf05f1cf6f2b5574ba091550a77d.tar.gz
test: don't use subprocesses where we don't have to
When running tests with `-n 0`, this shaves 4 seconds off the run time. When running the complete test suite with xdist, it takes 2 seconds longer!?
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r--tests/coveragetest.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index aae4df08..aad71134 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -78,6 +78,16 @@ class CoverageTest(
cov.stop()
return mod
+ def get_report(self, cov, squeeze=True, **kwargs):
+ """Get the report from `cov`, and canonicalize it."""
+ repout = io.StringIO()
+ kwargs.setdefault("show_missing", False)
+ cov.report(file=repout, **kwargs)
+ report = repout.getvalue().replace('\\', '/')
+ if squeeze:
+ report = re.sub(r" +", " ", report)
+ return report
+
def get_module_name(self):
"""Return a random module name to use for this test run."""
self.last_module_name = 'coverage_test_' + str(random.random())[2:]
@@ -451,6 +461,7 @@ class UsingModulesMixin:
# Parent class saves and restores sys.path, we can just modify it.
sys.path.append(nice_file(TESTS_DIR, "modules"))
sys.path.append(nice_file(TESTS_DIR, "moremodules"))
+ sys.path.append(nice_file(TESTS_DIR, "zipmods.zip"))
def command_line(args):