diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-09 07:19:56 -0500 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-09 07:19:56 -0500 |
| commit | f683ba3af6c539882dd0b4f750b476e2d9745ebe (patch) | |
| tree | 9ec0bd819f3d0a02785bdb5b6de1226dfe45a590 /test/backunittest.py | |
| parent | 44ae48c70337531a4b47b01e3bbe8a063ce69b0a (diff) | |
| download | python-coveragepy-f683ba3af6c539882dd0b4f750b476e2d9745ebe.tar.gz | |
Add assertIn for test use.
Diffstat (limited to 'test/backunittest.py')
| -rw-r--r-- | test/backunittest.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/backunittest.py b/test/backunittest.py index 7ec34f5..84a7f36 100644 --- a/test/backunittest.py +++ b/test/backunittest.py @@ -29,6 +29,13 @@ class TestCase(unittest.TestCase): if exp: self.fail(msg) + if _need('assertIn'): + def assertIn(self, member, container, msg=None): + """Assert that `member` is in `container`.""" + if member not in container: + msg = msg or ('%r not found in %r' % (member, container)) + self.fail(msg) + if _need('assertRaisesRegexp'): def assertRaisesRegexp(self, excClass, regexp, callobj, *args, **kw): """ Just like unittest.TestCase.assertRaises, @@ -46,7 +53,7 @@ class TestCase(unittest.TestCase): # Message provided, and it didn't match: fail! raise self.failureException( "Right exception, wrong message: " - "'%s' doesn't match '%s'" % (excMsg, regexp) + "%r doesn't match %r" % (excMsg, regexp) ) # No need to catch other exceptions: They'll fail the test all by # themselves! |
