summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-11-26 15:59:46 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-11-26 15:59:46 -0500
commitb17a7a8c1e686e8cf671e70e5023884c40faf633 (patch)
tree0870d58cccda45f594b65308b776dbba809e1073
parent10a2e79516ae41ec111dc15966feedd82cd67861 (diff)
downloadpython-coveragepy-b17a7a8c1e686e8cf671e70e5023884c40faf633.tar.gz
Fix two problems with xdist'ed tests
-rw-r--r--tests/test_process.py3
-rw-r--r--tests/test_results.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index 02e23e7..75d420a 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -1087,7 +1087,8 @@ class ProcessCoverageMixin(object):
# Find a place to put a .pth file.
pth_contents = "import coverage; coverage.process_startup()\n"
for pth_dir in possible_pth_dirs(): # pragma: part covered
- pth_path = os.path.join(pth_dir, "subcover.pth")
+ worker = os.environ.get('PYTEST_XDIST_WORKER', '')
+ pth_path = os.path.join(pth_dir, "subcover_{0}.pth".format(worker))
with open(pth_path, "w") as pth:
try:
pth.write(pth_contents)
diff --git a/tests/test_results.py b/tests/test_results.py
index 54c2f6d..c4d8ae5 100644
--- a/tests/test_results.py
+++ b/tests/test_results.py
@@ -40,6 +40,8 @@ class NumbersTest(CoverageTest):
self.assertAlmostEqual(n3.pc_covered, 86.666666666)
def test_pc_covered_str(self):
+ # Numbers._precision is a global, which is bad.
+ Numbers.set_precision(0)
n0 = Numbers(n_files=1, n_statements=1000, n_missing=0)
n1 = Numbers(n_files=1, n_statements=1000, n_missing=1)
n999 = Numbers(n_files=1, n_statements=1000, n_missing=999)
@@ -50,7 +52,7 @@ class NumbersTest(CoverageTest):
self.assertEqual(n1000.pc_covered_str, "0")
def test_pc_covered_str_precision(self):
- assert Numbers._precision == 0
+ # Numbers._precision is a global, which is bad.
Numbers.set_precision(1)
n0 = Numbers(n_files=1, n_statements=10000, n_missing=0)
n1 = Numbers(n_files=1, n_statements=10000, n_missing=1)