summaryrefslogtreecommitdiff
path: root/test/backunittest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-11-09 07:19:56 -0500
committerNed Batchelder <ned@nedbatchelder.com>2012-11-09 07:19:56 -0500
commit429868d515cc4ea74d625715512c57d3b5b93e73 (patch)
tree539e1e71c681d7721a0441e3108847129cb5a1f4 /test/backunittest.py
parentc260721a7bbe8d75368fc35daa719655217a83f2 (diff)
downloadpython-coveragepy-git-429868d515cc4ea74d625715512c57d3b5b93e73.tar.gz
Add assertIn for test use.
Diffstat (limited to 'test/backunittest.py')
-rw-r--r--test/backunittest.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/backunittest.py b/test/backunittest.py
index 7ec34f5c..84a7f36e 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!