summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-04-27 07:21:51 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2011-04-27 07:21:51 (GMT)
commit9490af2150f9cf86a092a5c4f6e408a969881851 (patch)
tree85b38f89424d57093e1f84dcba433b212c1c0df3 /Lib/unittest/case.py
parent793b531756a4752a167e29f53c4ff49ce2846c74 (diff)
parentedd117fd279a8c7339ec2d6d88633218ef9d891e (diff)
downloadcpython-9490af2150f9cf86a092a5c4f6e408a969881851.zip
cpython-9490af2150f9cf86a092a5c4f6e408a969881851.tar.gz
cpython-9490af2150f9cf86a092a5c4f6e408a969881851.tar.bz2
#11763: merge with 3.2.
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 8086bf9..881de6f 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -263,6 +263,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
@@ -1006,6 +1010,10 @@ class TestCase(object):
self.assertIsInstance(second, str, '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: