mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +01:00
src/test.py: Implement assertIs for old Python versions.
This commit is contained in:
parent
139cb39ec5
commit
2bcffdf523
14
src/test.py
14
src/test.py
@ -114,6 +114,20 @@ class SupyTestCase(unittest.TestCase):
|
|||||||
for irc in world.ircs[:]:
|
for irc in world.ircs[:]:
|
||||||
irc._reallyDie()
|
irc._reallyDie()
|
||||||
|
|
||||||
|
if sys.version_info < (2, 7, 0):
|
||||||
|
def assertIs(self, expr1, expr2, msg=None):
|
||||||
|
"""Just like self.assertTrue(a is b), but with a nicer default message."""
|
||||||
|
if expr1 is not expr2:
|
||||||
|
standardMsg = '%s is not %s' % (safe_repr(expr1),
|
||||||
|
safe_repr(expr2))
|
||||||
|
self.fail(self._formatMessage(msg, standardMsg))
|
||||||
|
|
||||||
|
def assertIsNot(self, expr1, expr2, msg=None):
|
||||||
|
"""Just like self.assertTrue(a is not b), but with a nicer default message."""
|
||||||
|
if expr1 is expr2:
|
||||||
|
standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
|
||||||
|
self.fail(self._formatMessage(msg, standardMsg))
|
||||||
|
|
||||||
|
|
||||||
class PluginTestCase(SupyTestCase):
|
class PluginTestCase(SupyTestCase):
|
||||||
"""Subclass this to write a test case for a plugin. See
|
"""Subclass this to write a test case for a plugin. See
|
||||||
|
Loading…
x
Reference in New Issue
Block a user