Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
34b32d62
Kaydet (Commit)
34b32d62
authored
Nis 27, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#11763: don't use difflib in TestCase.assertMultiLineEqual if the strings are too long.
üst
5dc6868f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
case.py
Lib/unittest/case.py
+8
-0
test_case.py
Lib/unittest/test/test_case.py
+36
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/case.py
Dosyayı görüntüle @
34b32d62
...
@@ -169,6 +169,10 @@ class TestCase(object):
...
@@ -169,6 +169,10 @@ class TestCase(object):
maxDiff
=
80
*
8
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
# Attribute used by TestSuite for classSetUp
_classSetupFailed
=
False
_classSetupFailed
=
False
...
@@ -900,6 +904,10 @@ class TestCase(object):
...
@@ -900,6 +904,10 @@ class TestCase(object):
'Second argument is not a string'
)
'Second argument is not a string'
)
if
first
!=
second
:
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
)
firstlines
=
first
.
splitlines
(
True
)
secondlines
=
second
.
splitlines
(
True
)
secondlines
=
second
.
splitlines
(
True
)
if
len
(
firstlines
)
==
1
and
first
.
strip
(
'
\r\n
'
)
==
first
:
if
len
(
firstlines
)
==
1
and
first
.
strip
(
'
\r\n
'
)
==
first
:
...
...
Lib/unittest/test/test_case.py
Dosyayı görüntüle @
34b32d62
...
@@ -667,6 +667,42 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
...
@@ -667,6 +667,42 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
else
:
else
:
self
.
fail
(
'assertMultiLineEqual did not fail'
)
self
.
fail
(
'assertMultiLineEqual did not fail'
)
def
testAssertEqual_diffThreshold
(
self
):
# check threshold value
self
.
assertEqual
(
self
.
_diffThreshold
,
2
**
16
)
# disable madDiff to get diff markers
self
.
maxDiff
=
None
# set a lower threshold value and add a cleanup to restore it
old_threshold
=
self
.
_diffThreshold
self
.
_diffThreshold
=
2
**
8
self
.
addCleanup
(
lambda
:
setattr
(
self
,
'_diffThreshold'
,
old_threshold
))
# under the threshold: diff marker (^) in error message
s
=
u'x'
*
(
2
**
7
)
with
self
.
assertRaises
(
self
.
failureException
)
as
cm
:
self
.
assertEqual
(
s
+
'a'
,
s
+
'b'
)
self
.
assertIn
(
'^'
,
str
(
cm
.
exception
))
self
.
assertEqual
(
s
+
'a'
,
s
+
'a'
)
# over the threshold: diff not used and marker (^) not in error message
s
=
u'x'
*
(
2
**
9
)
# if the path that uses difflib is taken, _truncateMessage will be
# called -- replace it with explodingTruncation to verify that this
# doesn't happen
def
explodingTruncation
(
message
,
diff
):
raise
SystemError
(
'this should not be raised'
)
old_truncate
=
self
.
_truncateMessage
self
.
_truncateMessage
=
explodingTruncation
self
.
addCleanup
(
lambda
:
setattr
(
self
,
'_truncateMessage'
,
old_truncate
))
s1
,
s2
=
s
+
'a'
,
s
+
'b'
with
self
.
assertRaises
(
self
.
failureException
)
as
cm
:
self
.
assertEqual
(
s1
,
s2
)
self
.
assertNotIn
(
'^'
,
str
(
cm
.
exception
))
self
.
assertEqual
(
str
(
cm
.
exception
),
'
%
r !=
%
r'
%
(
s1
,
s2
))
self
.
assertEqual
(
s
+
'a'
,
s
+
'a'
)
def
testAssertItemsEqual
(
self
):
def
testAssertItemsEqual
(
self
):
a
=
object
()
a
=
object
()
self
.
assertItemsEqual
([
1
,
2
,
3
],
[
3
,
2
,
1
])
self
.
assertItemsEqual
([
1
,
2
,
3
],
[
3
,
2
,
1
])
...
...
Misc/NEWS
Dosyayı görüntüle @
34b32d62
...
@@ -61,6 +61,9 @@ Core and Builtins
...
@@ -61,6 +61,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
11763
:
don
't use difflib in TestCase.assertMultiLineEqual if the
strings are too long.
- Issue #11236: getpass.getpass responds to ctrl-c or ctrl-z on terminal.
- Issue #11236: getpass.getpass responds to ctrl-c or ctrl-z on terminal.
- Issue #11768: The signal handler of the signal module only calls
- Issue #11768: The signal handler of the signal module only calls
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment