From 128fdb46cc7ff2311bf2c9d7fb17848024ac13a7 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 31 Aug 2010 22:44:43 -0400 Subject: Too many files start with 'cov', rename a few. --HG-- rename : covcov.ini => metacov.ini rename : test/coverage_coverage.py => test/meta_coverage.py --- allcoverage.cmd | 6 ++-- covcov.ini | 19 ---------- metacov.ini | 19 ++++++++++ test/coverage_coverage.py | 89 ----------------------------------------------- test/meta_coverage.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 111 deletions(-) delete mode 100644 covcov.ini create mode 100644 metacov.ini delete mode 100644 test/coverage_coverage.py create mode 100644 test/meta_coverage.py diff --git a/allcoverage.cmd b/allcoverage.cmd index dc7c9ee5..a12173ef 100644 --- a/allcoverage.cmd +++ b/allcoverage.cmd @@ -2,18 +2,18 @@ make --quiet testdata del .coverage.* -set COVERAGE_PROCESS_START=c:\ned\coverage\trunk\covcov.ini +set COVERAGE_PROCESS_START=c:\ned\coverage\trunk\metacov.ini set COVERAGE_COVERAGE=1 for %%v in (23 24 25 26 27 31 32) do ( call \ned\bin\switchpy c:\vpy\coverage\%%v python setup.py -q develop set COVERAGE_TEST_TRACER=c - python test\coverage_coverage.py run %1 %2 %3 %4 %5 %6 %7 %8 %9 + python test\meta_coverage.py run %1 %2 %3 %4 %5 %6 %7 %8 %9 del coverage\tracer.pyd ) set COVERAGE_PROCESS_START= set COVERAGE_COVERAGE= -python test\coverage_coverage.py report +python test\meta_coverage.py report diff --git a/covcov.ini b/covcov.ini deleted file mode 100644 index 7d009ea9..00000000 --- a/covcov.ini +++ /dev/null @@ -1,19 +0,0 @@ -# Settings to use when using coverage.py to measure itself. -[run] -branch = true -data_file = c:\ned\coverage\trunk\.coverage -parallel = true -source = - c:\ned\coverage\trunk\coverage - c:\ned\coverage\trunk\test - -[report] -exclude_lines = - # pragma: no cover - # pragma: recursive coverage - def __repr__ - if __name__ == .__main__.: - raise AssertionError - -omit = mock.py, ez_setup.py, distribute.py -ignore_errors = true diff --git a/metacov.ini b/metacov.ini new file mode 100644 index 00000000..7d009ea9 --- /dev/null +++ b/metacov.ini @@ -0,0 +1,19 @@ +# Settings to use when using coverage.py to measure itself. +[run] +branch = true +data_file = c:\ned\coverage\trunk\.coverage +parallel = true +source = + c:\ned\coverage\trunk\coverage + c:\ned\coverage\trunk\test + +[report] +exclude_lines = + # pragma: no cover + # pragma: recursive coverage + def __repr__ + if __name__ == .__main__.: + raise AssertionError + +omit = mock.py, ez_setup.py, distribute.py +ignore_errors = true diff --git a/test/coverage_coverage.py b/test/coverage_coverage.py deleted file mode 100644 index 199f7518..00000000 --- a/test/coverage_coverage.py +++ /dev/null @@ -1,89 +0,0 @@ -"""Coverage-test Coverage.py itself. - -Run as: - - $ python test/coverage_coverage.py run [NOSE_ARGS] - -to run and collect coverage, then: - - $ python test/coverage_coverage.py report - -to put the HTML report into the htmlcov directory. - -""" - -import os, shutil, sys -import nose - -HTML_DIR = "htmlcov" - -def run_tests_with_coverage(): - """Run the test suite with coverage measuring itself.""" - import coverage - - tracer = os.environ.get('COVERAGE_TEST_TRACER', 'c') - version = "%s%s" % sys.version_info[:2] - suffix = "%s_%s" % (version, tracer) - - cov = coverage.coverage(config_file="covcov.ini", data_suffix=suffix) - # Cheap trick: the coverage code itself is excluded from measurement, but - # if we clobber the cover_prefix in the coverage object, we can defeat the - # self-detection. - cov.cover_prefix = "Please measure coverage.py!" - cov.erase() - cov.start() - - # Re-import coverage to get it coverage tested! I don't understand all the - # mechanics here, but if I don't carry over the imported modules (in - # covmods), then things go haywire (os == None, eventually). - covmods = {} - covdir = os.path.split(coverage.__file__)[0] - # We have to make a list since we'll be deleting in the loop. - modules = list(sys.modules.items()) - for name, mod in modules: - if name.startswith('coverage'): - if hasattr(mod, '__file__') and mod.__file__.startswith(covdir): - covmods[name] = mod - del sys.modules[name] - 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. - print(":: Running nosetests %s" % " ".join(sys.argv[1:])) - try: - nose.run() - except SystemExit: - # nose3 seems to raise SystemExit, not sure why? - pass - - cov.stop() - print(":: Saving .coverage%s" % suffix) - cov.save() - -def report_on_combined_files(): - """Combine all the .coverage files and make an HTML report.""" - if os.path.exists(HTML_DIR): - shutil.rmtree(HTML_DIR) - - print(":: Writing HTML report to %s/index.html" % HTML_DIR) - import coverage - cov = coverage.coverage(config_file="covcov.ini") - cov.combine() - cov.save() - cov.html_report(directory=HTML_DIR) - - -try: - cmd = sys.argv[1] -except IndexError: - cmd = '' - -if cmd == 'run': - # Ugly hack: nose.run reads sys.argv directly, so here I delete my command - # argument so that sys.argv is left as just nose arguments. - del sys.argv[1] - run_tests_with_coverage() -elif cmd == 'report': - report_on_combined_files() -else: - print("Need 'run' or 'report'") diff --git a/test/meta_coverage.py b/test/meta_coverage.py new file mode 100644 index 00000000..1c71abf0 --- /dev/null +++ b/test/meta_coverage.py @@ -0,0 +1,89 @@ +"""Coverage-test Coverage.py itself. + +Run as: + + $ python test/meta_coverage.py run [NOSE_ARGS] + +to run and collect coverage, then: + + $ python test/meta_coverage.py report + +to put the HTML report into the htmlcov directory. + +""" + +import os, shutil, sys +import nose + +HTML_DIR = "htmlcov" + +def run_tests_with_coverage(): + """Run the test suite with coverage measuring itself.""" + import coverage + + tracer = os.environ.get('COVERAGE_TEST_TRACER', 'c') + version = "%s%s" % sys.version_info[:2] + suffix = "%s_%s" % (version, tracer) + + cov = coverage.coverage(config_file="metacov.ini", data_suffix=suffix) + # Cheap trick: the coverage code itself is excluded from measurement, but + # if we clobber the cover_prefix in the coverage object, we can defeat the + # self-detection. + cov.cover_prefix = "Please measure coverage.py!" + cov.erase() + cov.start() + + # Re-import coverage to get it coverage tested! I don't understand all the + # mechanics here, but if I don't carry over the imported modules (in + # covmods), then things go haywire (os == None, eventually). + covmods = {} + covdir = os.path.split(coverage.__file__)[0] + # We have to make a list since we'll be deleting in the loop. + modules = list(sys.modules.items()) + for name, mod in modules: + if name.startswith('coverage'): + if hasattr(mod, '__file__') and mod.__file__.startswith(covdir): + covmods[name] = mod + del sys.modules[name] + 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. + print(":: Running nosetests %s" % " ".join(sys.argv[1:])) + try: + nose.run() + except SystemExit: + # nose3 seems to raise SystemExit, not sure why? + pass + + cov.stop() + print(":: Saving .coverage%s" % suffix) + cov.save() + +def report_on_combined_files(): + """Combine all the .coverage files and make an HTML report.""" + if os.path.exists(HTML_DIR): + shutil.rmtree(HTML_DIR) + + print(":: Writing HTML report to %s/index.html" % HTML_DIR) + import coverage + cov = coverage.coverage(config_file="metacov.ini") + cov.combine() + cov.save() + cov.html_report(directory=HTML_DIR) + + +try: + cmd = sys.argv[1] +except IndexError: + cmd = '' + +if cmd == 'run': + # Ugly hack: nose.run reads sys.argv directly, so here I delete my command + # argument so that sys.argv is left as just nose arguments. + del sys.argv[1] + run_tests_with_coverage() +elif cmd == 'report': + report_on_combined_files() +else: + print("Need 'run' or 'report'") -- cgit v1.2.1