summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CoverageTestRunner.py17
-rw-r--r--subdir/foo.py3
2 files changed, 16 insertions, 4 deletions
diff --git a/CoverageTestRunner.py b/CoverageTestRunner.py
index 5bbcb59..c81fa70 100644
--- a/CoverageTestRunner.py
+++ b/CoverageTestRunner.py
@@ -32,6 +32,7 @@ class CoverageTestResult(unittest.TestResult):
self.total = total
self.lastmsg = ""
self.coverage_missed = []
+ self.coverage_excluded = []
self.timings = []
def addCoverageMissed(self, filename, statements, missed_statements,
@@ -39,6 +40,9 @@ class CoverageTestResult(unittest.TestResult):
self.coverage_missed.append((filename, statements, missed_statements,
missed_description))
+ def addCoverageExcluded(self, statements):
+ self.coverage_excluded += statements
+
def wasSuccessful(self, ignore_coverage=False):
return (unittest.TestResult.wasSuccessful(self) and
(ignore_coverage or not self.coverage_missed))
@@ -145,11 +149,15 @@ class CoverageTestRunner:
del sys.path[0]
suite.run(result)
coverage.stop()
- filename, stmts, missed, missed_desc = coverage.analysis(module)
+ filename, stmts, excluded, missed, missed_desc = \
+ coverage.analysis2(module)
+ if self._dirname and filename.startswith(self._dirname):
+ filename = filename[len(self._dirname):]
if missed:
- if self._dirname and filename.startswith(self._dirname):
- filename = filename[len(self._dirname):]
result.addCoverageMissed(filename, stmts, missed, missed_desc)
+ print "xxxx"
+ print "excluded:", excluded
+ result.addCoverageExcluded(excluded)
end_time = time.time()
@@ -177,6 +185,9 @@ class CoverageTestRunner:
print "%d failures, %d errors" % (len(result.failures),
len(result.errors))
+ if result.coverage_excluded:
+ print len(result.coverage_excluded), "excluded statements"
+
if end_time - start_time > 10:
print
print "Slowest tests:"
diff --git a/subdir/foo.py b/subdir/foo.py
index 8fdeca5..6711dd4 100644
--- a/subdir/foo.py
+++ b/subdir/foo.py
@@ -5,5 +5,6 @@ class Foo:
return True
else:
import time
- time.sleep(12)
+ time.sleep(0)
return False
+ pass # pragma: no cover