backporting assertIs and assertIsNot to objcache.py

This commit is contained in:
Ilan Schnell 2012-08-12 23:05:53 -05:00
commit 2c25966dd6

View file

@ -2,9 +2,23 @@
from llvm.core import *
import logging, unittest
import logging, sys, unittest
class TestObjCache(unittest.TestCase):
if sys.version_info[:2] < (2, 7):
def assertIs(self, expr1, expr2, msg=None):
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):
if expr1 is expr2:
standardMsg = 'unexpectedly identical: %s' % (safe_repr(
expr1),)
self.fail(self._formatMessage(msg, standardMsg))
def test_objcache(self):
logging.debug("Testing module aliasing ..")
m1 = Module.new('a')