Kaydet (Commit) 225a099f authored tarafından Michael Foord's avatar Michael Foord

unittest.TestCase uses safe_repr for producing failure messages. Partial fix for issue 7956

üst 456e1652
......@@ -17,6 +17,7 @@ from copy import deepcopy
from cStringIO import StringIO
import pickle
### Support code
################################################################
......@@ -2557,21 +2558,28 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
self.assertRaises(unittest.TestCase.failureException,
self.assertDictContainsSubset, {'a': 2}, {'a': 1},
'.*Mismatched values:.*')
with self.assertRaises(self.failureException):
self.assertDictContainsSubset({1: "one"}, {})
self.assertRaises(unittest.TestCase.failureException,
self.assertDictContainsSubset, {'c': 1}, {'a': 1},
'.*Missing:.*')
with self.assertRaises(self.failureException):
self.assertDictContainsSubset({'a': 2}, {'a': 1})
self.assertRaises(unittest.TestCase.failureException,
self.assertDictContainsSubset, {'a': 1, 'c': 1},
{'a': 1}, '.*Missing:.*')
with self.assertRaises(self.failureException):
self.assertDictContainsSubset({'c': 1}, {'a': 1})
self.assertRaises(unittest.TestCase.failureException,
self.assertDictContainsSubset, {'a': 1, 'c': 1},
{'a': 1}, '.*Missing:.*Mismatched values:.*')
with self.assertRaises(self.failureException):
self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
with self.assertRaises(self.failureException):
self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
@unittest.expectedFailure
def test_crazy(self):
one = ''.join(chr(i) for i in range(255))
two = u'\uFFFD'
first = {'foo': one}
second = {'foo': two}
self.assertDictContainsSubset(first, second)
def testAssertEqual(self):
equal_pairs = [
......
This diff is collapsed.
"""Various utility functions."""
def safe_repr(obj):
try:
return repr(obj)
except Exception:
return object.__repr__(obj)
def strclass(cls):
return "%s.%s" % (cls.__module__, cls.__name__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment