summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-09-22 09:55:35 -0400
committerNed Batchelder <ned@nedbatchelder.com>2016-09-22 09:55:35 -0400
commit7a72b3788ad02d530420c26130cffcd81b9673f2 (patch)
treef696ea8895e742b885d6a6247f0d26dd55583b1d /tests/test_process.py
parenta3a3f227d2d5fe96a3667ca51bad9c9c9a2142a1 (diff)
downloadpython-coveragepy-git-7a72b3788ad02d530420c26130cffcd81b9673f2.tar.gz
Ensure random suffixes are different after forking
Diffstat (limited to 'tests/test_process.py')
-rw-r--r--tests/test_process.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index ec19aed9..aa2045fd 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -23,13 +23,13 @@ TRY_EXECFILE = os.path.join(os.path.dirname(__file__), "modules/process_test/try
class ProcessTest(CoverageTest):
"""Tests of the per-process behavior of coverage.py."""
+ def data_files(self):
+ """Return the names of coverage data files in this directory."""
+ return [f for f in os.listdir('.') if (f.startswith('.coverage.') or f == '.coverage')]
+
def number_of_data_files(self):
"""Return the number of coverage data files in this directory."""
- num = 0
- for f in os.listdir('.'):
- if f.startswith('.coverage.') or f == '.coverage':
- num += 1
- return num
+ return len(self.data_files())
def test_save_on_exit(self):
self.make_file("mycode.py", """\
@@ -577,6 +577,11 @@ class ProcessTest(CoverageTest):
# .coverage.machine.123 files.
self.assertEqual(self.number_of_data_files(), 2)
+ # The two data files should have different random numbers at the end of
+ # the file name.
+ nums = set(name.rpartition(".")[-1] for name in self.data_files())
+ self.assertEqual(len(nums), 2, "Same random: %s" % (self.data_files(),))
+
# Combine the parallel coverage data files into .coverage .
self.run_command("coverage combine")
self.assert_exists(".coverage")