From be6693a25123d8e8cf80aca5cb9a73a8f81dd584 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 8 Dec 2012 22:00:49 -0500 Subject: A blunt instrument for tracking down problems during testing. --- Makefile | 2 +- coverage/control.py | 7 +++++++ test/coveragetest.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89685498..031a14fe 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ tests: tox -e py27 metacov: - COVERAGE_COVERAGE=yes tox + COVERAGE_COVERAGE=yes tox -e py27 metahtml: python igor.py combine_html diff --git a/coverage/control.py b/coverage/control.py index fa441cd1..44837f14 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -439,6 +439,10 @@ class coverage(object): socket.gethostname(), 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) @@ -701,3 +705,6 @@ def process_startup(): cov.cover_dir = "Please measure coverage.py!" cov.start() cov._warn_no_data = False + + +_TEST_NAME_FILE = "" # r"c:\foo\covtest.txt" diff --git a/test/coveragetest.py b/test/coveragetest.py index 73284638..7dee7ebb 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -40,6 +40,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)) + # Tell newer unittest implementations to print long helpful messages. self.longMessage = True -- cgit v1.2.1