diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-25 09:31:20 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-25 09:31:20 -0400 |
commit | ffb82b1d4ce8553ac230d3ecabbf094c4c20d140 (patch) | |
tree | c63363d35149c15590604f051c9c332eed707d9b /test/coveragetest.py | |
parent | 02e3d4392b25b8c3fff9e7a00c86665d26fe1ba9 (diff) | |
download | python-coveragepy-git-ffb82b1d4ce8553ac230d3ecabbf094c4c20d140.tar.gz |
Add an assert_matches method, and tests to prove it works.
Diffstat (limited to 'test/coveragetest.py')
-rw-r--r-- | test/coveragetest.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index b1f4644c..32da6e66 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -1,6 +1,6 @@ """Base test case class for coverage testing.""" -import imp, os, random, shutil, sys, tempfile, textwrap, unittest +import imp, os, random, re, shutil, sys, tempfile, textwrap, unittest import coverage from coverage.backward import set, sorted, StringIO # pylint: disable-msg=W0622 @@ -268,3 +268,9 @@ class CoverageTest(unittest.TestCase): def assert_equal_sets(self, s1, s2): """Assert that the two arguments are equal as sets.""" self.assertEqual(set(s1), set(s2)) + + def assert_matches(self, s, regex): + """Assert that `s` matches `regex`.""" + m = re.search(regex, s) + if not m: + raise self.failureException("%r doesn't match %r" % (s, regex)) |