diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | coverage/control.py | 16 | ||||
-rw-r--r-- | test/coveragetest.py | 8 |
3 files changed, 15 insertions, 11 deletions
@@ -41,7 +41,7 @@ tests: tox -e py27 metacov: - COVERAGE_COVERAGE=yes tox -e py27 + COVERAGE_COVERAGE=yes tox metahtml: python igor.py combine_html diff --git a/coverage/control.py b/coverage/control.py index 44837f14..1a475a58 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -435,14 +435,16 @@ class coverage(object): # plenty of distinguishing information. We do this here in # `save()` at the last minute so that the pid will be correct even # if the process forks. - data_suffix = "%s.%s.%06d" % ( - socket.gethostname(), os.getpid(), + extra = "" + if _TEST_NAME_FILE: + f = open(_TEST_NAME_FILE) + test_name = f.read() + f.close() + extra = "." + test_name + data_suffix = "%s%s.%s.%06d" % ( + socket.gethostname(), extra, os.getpid(), random.randint(0, 999999) ) - if _TEST_NAME_FILE: - with open(_TEST_NAME_FILE) as f: - test_name = f.read() - data_suffix += "." + test_name self._harvest_data() self.data.write(suffix=data_suffix) @@ -707,4 +709,4 @@ def process_startup(): cov._warn_no_data = False -_TEST_NAME_FILE = "" # r"c:\foo\covtest.txt" +_TEST_NAME_FILE = "/tmp/covtest.txt" # r"c:\foo\covtest.txt" diff --git a/test/coveragetest.py b/test/coveragetest.py index 7dee7ebb..ced68fc8 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -5,6 +5,7 @@ import glob, imp, os, random, shlex, shutil, sys, tempfile, textwrap import coverage from coverage.backward import sorted, StringIO # pylint: disable=W0622 from coverage.backward import to_bytes +from coverage.control import _TEST_NAME_FILE from backtest import run_command from backunittest import TestCase @@ -40,9 +41,10 @@ class CoverageTest(TestCase): def setUp(self): super(CoverageTest, self).setUp() - if coverage._TEST_NAME_FILE: - with open(coverage._TEST_NAME_FILE, "w") as f: - f.write("%s_%s" % (self.__class__.__name__, self._testMethodName)) + if _TEST_NAME_FILE: + f = open(_TEST_NAME_FILE, "w") + f.write("%s_%s" % (self.__class__.__name__, self._testMethodName)) + f.close() # Tell newer unittest implementations to print long helpful messages. self.longMessage = True |