mirror of
https://github.com/python/cpython.git
synced 2025-10-02 21:25:24 +00:00
Extract error message truncating into a method (unittest.TestCase._truncateMessage).
This commit is contained in:
parent
0100702b9a
commit
a441287f79
1 changed files with 6 additions and 4 deletions
|
@ -690,13 +690,15 @@ class TestCase(object):
|
||||||
diffMsg = '\n' + '\n'.join(
|
diffMsg = '\n' + '\n'.join(
|
||||||
difflib.ndiff(pprint.pformat(seq1).splitlines(),
|
difflib.ndiff(pprint.pformat(seq1).splitlines(),
|
||||||
pprint.pformat(seq2).splitlines()))
|
pprint.pformat(seq2).splitlines()))
|
||||||
if max_diff is None or len(diffMsg) <= max_diff:
|
standardMsg = self._truncateMessage(standardMsg, diffMsg, max_diff)
|
||||||
standardMsg += diffMsg
|
|
||||||
else:
|
|
||||||
standardMsg += diffMsg[:max_diff] + TRUNCATED_DIFF
|
|
||||||
msg = self._formatMessage(msg, standardMsg)
|
msg = self._formatMessage(msg, standardMsg)
|
||||||
self.fail(msg)
|
self.fail(msg)
|
||||||
|
|
||||||
|
def _truncateMessage(self, message, diff, max_diff):
|
||||||
|
if max_diff is None or len(diff) <= max_diff:
|
||||||
|
return message + diff
|
||||||
|
return message + diff[:max_diff] + TRUNCATED_DIFF
|
||||||
|
|
||||||
def assertListEqual(self, list1, list2, msg=None):
|
def assertListEqual(self, list1, list2, msg=None):
|
||||||
"""A list-specific equality assertion.
|
"""A list-specific equality assertion.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue