Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(19)

Unified Diff: Lib/unittest/case.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/turtle.py ('k') | Lib/unittest/test/test_case.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/unittest/case.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/unittest/case.py Mon Jul 25 09:47:18 2011 -0400
@@ -218,6 +218,27 @@
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.
@@ -289,7 +310,7 @@
# 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 = {}
+ self._type_equality_funcs = _TypeEqualityDict(self)
self.addTypeEqualityFunc(dict, 'assertDictEqual')
self.addTypeEqualityFunc(list, 'assertListEqual')
self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
@@ -622,8 +643,6 @@
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
« no previous file with comments | « Lib/turtle.py ('k') | Lib/unittest/test/test_case.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+