mirror of
https://github.com/python/cpython.git
synced 2025-09-08 01:41:19 +00:00
#11763: don't use difflib in TestCase.assertMultiLineEqual if the strings are too long.
This commit is contained in:
parent
72387f90fd
commit
935a588825
3 changed files with 45 additions and 0 deletions
|
@ -346,6 +346,9 @@ class TestCase(object):
|
|||
|
||||
longMessage = False
|
||||
|
||||
# If a string is longer than _diffThreshold, use normal comparison instead
|
||||
# of difflib. See #11763.
|
||||
_diffThreshold = 2**16
|
||||
|
||||
def __init__(self, methodName='runTest'):
|
||||
"""Create an instance of the class that will use the named test
|
||||
|
@ -955,6 +958,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)
|
||||
standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True), second.splitlines(True)))
|
||||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue