mirror of
https://github.com/python/cpython.git
synced 2025-08-15 22:30:42 +00:00
#11763: don't use difflib in TestCase.assertMultiLineEqual if the strings are too long.
This commit is contained in:
parent
5dc6868f25
commit
34b32d62f8
3 changed files with 47 additions and 0 deletions
|
@ -169,6 +169,10 @@ class TestCase(object):
|
|||
|
||||
maxDiff = 80*8
|
||||
|
||||
# If a string is longer than _diffThreshold, use normal comparison instead
|
||||
# of difflib. See #11763.
|
||||
_diffThreshold = 2**16
|
||||
|
||||
# Attribute used by TestSuite for classSetUp
|
||||
|
||||
_classSetupFailed = False
|
||||
|
@ -900,6 +904,10 @@ class TestCase(object):
|
|||
'Second argument is not a string')
|
||||
|
||||
if first != second:
|
||||
# don't use difflib if the strings are too long
|
||||
if (len(first) > self._diffThreshold or
|
||||
len(second) > self._diffThreshold):
|
||||
self._baseAssertEqual(first, second, msg)
|
||||
firstlines = first.splitlines(True)
|
||||
secondlines = second.splitlines(True)
|
||||
if len(firstlines) == 1 and first.strip('\r\n') == first:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue