diff options
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r-- | tests/coveragetest.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index aa851954..fa55dec3 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -1,6 +1,6 @@ """Base test case class for coverage testing.""" -import glob, os, random, shlex, shutil, sys, tempfile, textwrap +import glob, os, random, re, shlex, shutil, sys, tempfile, textwrap import atexit, collections import coverage @@ -486,6 +486,22 @@ class CoverageTest(TestCase): print(output) return status, output + def report_from_command(self, cmd): + """Return the report from the `cmd`, with some convenience added.""" + report = self.run_command(cmd).replace('\\', '/') + self.assertNotIn("error", report.lower()) + return report + + def line_count(self, report): + """How many lines are in `report`?""" + self.assertEqual(report.split('\n')[-1], "") + return len(report.split('\n')) - 1 + + def last_line_squeezed(self, report): + """Return the last line of `report` with the spaces squeezed down.""" + last_line = report.split('\n')[-2] + return re.sub(r"\s+", " ", last_line) + # We run some tests in temporary directories, because they may need to make # files for the tests. But this is expensive, so we can change per-class # whether a temp dir is used or not. It's easy to forget to set that |