diff options
author | Ezio Melotti <none@none> | 2011-04-27 09:45:46 +0300 |
---|---|---|
committer | Ezio Melotti <none@none> | 2011-04-27 09:45:46 +0300 |
commit | 34b32d62f85f198ca0c92b367e04a08febb87532 (patch) | |
tree | 938636c04083f9be5d9df818283975d90b574098 /Lib/unittest/case.py | |
parent | 5dc6868f258d71e532e2bcc2ae6a03fa9ea47016 (diff) | |
download | cpython-git-34b32d62f85f198ca0c92b367e04a08febb87532.tar.gz |
#11763: don't use difflib in TestCase.assertMultiLineEqual if the strings are too long.
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r-- | Lib/unittest/case.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index ecb6a3e419..dcaae93aed 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -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: |