summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@iki.fi>2008-05-18 16:39:29 +0300
committerLars Wirzenius <liw@iki.fi>2008-05-18 16:39:29 +0300
commit0bc0b2d51ca6176c000efd2f6d578e97ebaf440e (patch)
tree09182047ad67ae947c5ccfd061352bea790e0169
parent20aa263d1230bc0ff96dd99253841c6cd98e49b0 (diff)
parentc49fee7c37e71413641ccaa34b9a8b2b2cdb93a1 (diff)
downloadcoverage-test-runner-0bc0b2d51ca6176c000efd2f6d578e97ebaf440e.tar.gz
Merged from temporary branch to add support for '#pgrama: no cover'.
-rw-r--r--CoverageTestRunner.py1
-rw-r--r--README19
2 files changed, 20 insertions, 0 deletions
diff --git a/CoverageTestRunner.py b/CoverageTestRunner.py
index 77da379..7a6370a 100644
--- a/CoverageTestRunner.py
+++ b/CoverageTestRunner.py
@@ -134,6 +134,7 @@ class CoverageTestRunner:
for module, test_module, suite in module_pairs:
coverage.erase()
+ coverage.exclude("#\s*pragma: no cover")
coverage.start()
sys.path.insert(0, os.path.dirname(module.__file__))
reload(module)
diff --git a/README b/README
index 533bff4..fb58879 100644
--- a/README
+++ b/README
@@ -87,6 +87,25 @@ executed during the tests, a list of files and statement numbers is
included in the output.
+Excluding some statements from the coverage analysis
+====================================================
+
+Use "# pragma: no cover" to exclude some statements from being included
+in the coverage analysis. The line with that comment is excluded. If
+the line is an if, while, def, or similar, with a "body", the body
+is also excluded. For example:
+
+ if always_true_during_testing:
+ print foo
+ else: # pragma: no cover
+ print bar
+
+The last two lines of codes are excluded from coverage analysis even
+if the test suite does not execute them.
+
+You should only use this after thorough consideration.
+
+
Your tests are too slow
=======================