Fix SupyTestCase.assert* with Python 2.6.

This commit is contained in:
Valentin Lorentz 2013-05-15 18:52:56 +02:00
parent 65afe65ae6
commit f42023bf19

View File

@ -117,28 +117,28 @@ class SupyTestCase(unittest.TestCase):
def assertIn(self, member, container, msg=None): def assertIn(self, member, container, msg=None):
"""Just like self.assertTrue(a in b), but with a nicer default message.""" """Just like self.assertTrue(a in b), but with a nicer default message."""
if member not in container: if member not in container:
standardMsg = '%s not found in %s' % (safe_repr(member), standardMsg = '%s not found in %s' % (repr(member),
safe_repr(container)) repr(container))
self.fail(self._formatMessage(msg, standardMsg)) self.fail(self._formatMessage(msg, standardMsg))
def assertNotIn(self, member, container, msg=None): def assertNotIn(self, member, container, msg=None):
"""Just like self.assertTrue(a not in b), but with a nicer default message.""" """Just like self.assertTrue(a not in b), but with a nicer default message."""
if member in container: if member in container:
standardMsg = '%s unexpectedly found in %s' % (safe_repr(member), standardMsg = '%s unexpectedly found in %s' % (repr(member),
safe_repr(container)) repr(container))
self.fail(self._formatMessage(msg, standardMsg)) self.fail(self._formatMessage(msg, standardMsg))
def assertIs(self, expr1, expr2, msg=None): def assertIs(self, expr1, expr2, msg=None):
"""Just like self.assertTrue(a is b), but with a nicer default message.""" """Just like self.assertTrue(a is b), but with a nicer default message."""
if expr1 is not expr2: if expr1 is not expr2:
standardMsg = '%s is not %s' % (safe_repr(expr1), standardMsg = '%s is not %s' % (repr(expr1),
safe_repr(expr2)) repr(expr2))
self.fail(self._formatMessage(msg, standardMsg)) self.fail(self._formatMessage(msg, standardMsg))
def assertIsNot(self, expr1, expr2, msg=None): def assertIsNot(self, expr1, expr2, msg=None):
"""Just like self.assertTrue(a is not b), but with a nicer default message.""" """Just like self.assertTrue(a is not b), but with a nicer default message."""
if expr1 is expr2: if expr1 is expr2:
standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),) standardMsg = 'unexpectedly identical: %s' % (repr(expr1),)
self.fail(self._formatMessage(msg, standardMsg)) self.fail(self._formatMessage(msg, standardMsg))