44
45
if _PY_MINOR == 4 and _PY_MICRO < 3:
45
46
FIX_HTTPRETTY = True
48
# For now add these on, taken from python 2.7 + slightly adjusted. Drop
49
# all this once Python 2.6 is dropped as a minimum requirement.
50
class TestCase(unittest.TestCase):
52
super(TestCase, self).setUp()
53
self.__all_cleanups = ExitStack()
56
self.__all_cleanups.close()
57
unittest.TestCase.tearDown(self)
59
def addCleanup(self, function, *args, **kws):
60
self.__all_cleanups.callback(function, *args, **kws)
62
def assertIs(self, expr1, expr2, msg=None):
63
if expr1 is not expr2:
64
standardMsg = '%r is not %r' % (expr1, expr2)
65
self.fail(self._formatMessage(msg, standardMsg))
67
def assertIn(self, member, container, msg=None):
68
if member not in container:
69
standardMsg = '%r not found in %r' % (member, container)
70
self.fail(self._formatMessage(msg, standardMsg))
72
def assertNotIn(self, member, container, msg=None):
73
if member in container:
74
standardMsg = '%r unexpectedly found in %r'
75
standardMsg = standardMsg % (member, container)
76
self.fail(self._formatMessage(msg, standardMsg))
78
def assertIsNone(self, value, msg=None):
80
standardMsg = '%r is not None'
81
standardMsg = standardMsg % (value)
82
self.fail(self._formatMessage(msg, standardMsg))
84
def assertIsInstance(self, obj, cls, msg=None):
85
"""Same as self.assertTrue(isinstance(obj, cls)), with a nicer
87
if not isinstance(obj, cls):
88
standardMsg = '%s is not an instance of %r' % (repr(obj), cls)
89
self.fail(self._formatMessage(msg, standardMsg))
91
def assertDictContainsSubset(self, expected, actual, msg=None):
94
for k, v in expected.items():
98
mismatched.append('%r, expected: %r, actual: %r'
101
if len(missing) == 0 and len(mismatched) == 0:
106
standardMsg = 'Missing: %r' % ','.join(m for m in missing)
110
standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
112
self.fail(self._formatMessage(msg, standardMsg))
116
class TestCase(unittest.TestCase):
120
48
# Makes the old path start
121
49
# with new base instead of whatever
122
50
# it previously had