summaryrefslogtreecommitdiff
path: root/tests/coveragetest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-06-03 21:41:12 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-06-03 21:41:12 -0400
commitdfe2fa5e5db2cf29a1b43b0abf61be3b545db270 (patch)
treeb9309998f9699848654101ed2d27d00e11211a27 /tests/coveragetest.py
parent8b5e0c98a9bae35595e4ca0497fd0e57c3c37827 (diff)
downloadpython-coveragepy-git-dfe2fa5e5db2cf29a1b43b0abf61be3b545db270.tar.gz
Round fail-under result same as others. Fixed #284.
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r--tests/coveragetest.py18
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