diff options
Diffstat (limited to 'test/coveragetest.py')
-rw-r--r-- | test/coveragetest.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index 635b05b2..b1f4644c 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -125,8 +125,7 @@ class CoverageTest(unittest.TestCase): return sorted(arcs) def check_coverage(self, text, lines=None, missing="", excludes=None, - report="", arcs=None, arcs_missing=None, - arcz=None, arcz_missing=None): + report="", arcz=None, arcz_missing="", arcz_unpredicted=""): """Check the coverage measurement of `text`. The source `text` is run and measured. `lines` are the line numbers @@ -134,6 +133,12 @@ class CoverageTest(unittest.TestCase): are regexes to match against for excluding lines, and `report` is the text of the measurement report. + For arc measurement, `arcz` is a string that can be decoded into arcs + in the code (see `arcz_to_arcs` for the encoding scheme), + `arcz_missing` are the arcs that are not executed, and + `arcs_unpredicted` are the arcs executed in the code, but not deducible + from the code. + """ # We write the code into a file so that we can import it. # Coverage wants to deal with things as modules with file names. @@ -141,10 +146,11 @@ class CoverageTest(unittest.TestCase): self.make_file(modname+".py", text) + arcs = arcs_missing = arcs_unpredicted = None if arcz is not None: arcs = self.arcz_to_arcs(arcz) - if arcz_missing is not None: - arcs_missing = self.arcz_to_arcs(arcz_missing) + arcs_missing = self.arcz_to_arcs(arcz_missing or "") + arcs_unpredicted = self.arcz_to_arcs(arcz_unpredicted or "") # Start up Coverage. cov = coverage.coverage(branch=(arcs_missing is not None)) @@ -194,6 +200,9 @@ class CoverageTest(unittest.TestCase): if arcs_missing is not None: self.assertEqual(analysis.arcs_missing(), arcs_missing) + if arcs_unpredicted is not None: + self.assertEqual(analysis.arcs_unpredicted(), arcs_unpredicted) + if report: frep = StringIO() cov.report(mod, file=frep) |