summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-07-13 00:23:43 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-07-13 00:23:43 (GMT)
commit08506389575285bc3c316e0465fb9ae9c77bc18f (patch)
tree6f163636d6dd09e0fedceb98df3ab2946f6b509b
parent093c8e4bf053dfe5a9b46945cca2113e80809dfc (diff)
parent34b2b263db8dce3c980ec2a5061da4b7cc3c9106 (diff)
downloadcpython-08506389575285bc3c316e0465fb9ae9c77bc18f.zip
cpython-08506389575285bc3c316e0465fb9ae9c77bc18f.tar.gz
cpython-08506389575285bc3c316e0465fb9ae9c77bc18f.tar.bz2
merge 3.2 (#12544)
-rw-r--r--Lib/unittest/case.py25
1 files changed, 3 insertions, 22 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 5b7c29d..d82fa20 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -218,27 +218,6 @@ class _AssertWarnsContext(_AssertRaisesBaseContext):
self._raiseFailure("{} not triggered".format(exc_name))
-class _TypeEqualityDict(object):
-
- def __init__(self, testcase):
- self.testcase = testcase
- self._store = {}
-
- def __setitem__(self, key, value):
- self._store[key] = value
-
- def __getitem__(self, key):
- value = self._store[key]
- if isinstance(value, str):
- return getattr(self.testcase, value)
- return value
-
- def get(self, key, default=None):
- if key in self._store:
- return self[key]
- return default
-
-
class TestCase(object):
"""A class whose instances are single test cases.
@@ -310,7 +289,7 @@ class TestCase(object):
# Map types to custom assertEqual functions that will compare
# instances of said type in more detail to generate a more useful
# error message.
- self._type_equality_funcs = _TypeEqualityDict(self)
+ self._type_equality_funcs = {}
self.addTypeEqualityFunc(dict, 'assertDictEqual')
self.addTypeEqualityFunc(list, 'assertListEqual')
self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
@@ -643,6 +622,8 @@ class TestCase(object):
if type(first) is type(second):
asserter = self._type_equality_funcs.get(type(first))
if asserter is not None:
+ if isinstance(asserter, str):
+ asserter = getattr(self, asserter)
return asserter
return self._baseAssertEqual