From fac7f3e1011df358f19e3f3ba25a695d1fb95669 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 29 Nov 2009 07:18:07 -0500 Subject: Fix some self-measurement problems. Now coverage_coverage.py works again (had to be sure to stop coverage if check_coverage threw an exception). --- test/coverage_coverage.py | 6 +++++- test/coveragetest.py | 13 +++++++------ test/test_api.py | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/coverage_coverage.py b/test/coverage_coverage.py index e1e7674..64380ab 100644 --- a/test/coverage_coverage.py +++ b/test/coverage_coverage.py @@ -30,12 +30,16 @@ import coverage # don't warn about re-import: pylint: disable-msg=W0404 sys.modules.update(covmods) # Run nosetests, with the arguments from our command line. +nose_args = sys.argv[1:] +print(":: Running nosetests %s" % " ".join(nose_args)) import nose -nose.run(sys.argv[1:]) +nose.run(nose_args) cov.stop() +print(":: Saving .coverage") cov.save() +print(":: Writing HTML report to %s/index.html" % HTML_DIR) cov.clear_exclude() cov.exclude("#pragma: no cover") cov.exclude("def __repr__") diff --git a/test/coveragetest.py b/test/coveragetest.py index 1fb0472..073dc39 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -168,12 +168,13 @@ class CoverageTest(TestCase): cov.exclude(exc) cov.start() - # Import the python file, executing it. - mod = self.import_module(modname) - - # Stop Coverage. - cov.stop() - + try: + # Import the python file, executing it. + mod = self.import_module(modname) + finally: + # Stop Coverage. + cov.stop() + # Clean up our side effects del sys.modules[modname] diff --git a/test/test_api.py b/test/test_api.py index 932606f..7308cdc 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -8,6 +8,9 @@ from coverage.backward import StringIO sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k from coveragetest import CoverageTest +# This file uses the singleton module interface. Prevent it from writing +# .coverage files at exit. +coverage.use_cache(0) class ApiTest(CoverageTest): """Api-oriented tests for Coverage.""" -- cgit v1.2.1