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
935a5888
Kaydet (Commit)
935a5888
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
72387f90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
0 deletions
+45
-0
test_unittest.py
Lib/test/test_unittest.py
+35
-0
unittest.py
Lib/unittest.py
+7
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_unittest.py
Dosyayı görüntüle @
935a5888
...
...
@@ -2719,6 +2719,41 @@ test case
# no fair testing ourself with ourself, use assertEqual..
self
.
assertEqual
(
sample_text_error
,
str
(
e
))
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
=
'x'
*
(
2
**
7
)
try
:
self
.
assertMultiLineEqual
(
s
+
'a'
,
s
+
'b'
)
except
self
.
failureException
as
exc
:
err_msg
=
str
(
exc
)
else
:
self
.
fail
(
'assertEqual unexpectedly succeeded'
)
self
.
assertIn
(
'^'
,
err_msg
)
self
.
assertMultiLineEqual
(
s
+
'a'
,
s
+
'a'
)
# over the threshold: diff not used and marker (^) not in error message
s
=
'x'
*
(
2
**
9
)
s1
,
s2
=
s
+
'a'
,
s
+
'b'
try
:
self
.
assertMultiLineEqual
(
s1
,
s2
)
except
self
.
failureException
as
exc
:
err_msg
=
str
(
exc
)
else
:
self
.
fail
(
'assertEqual unexpectedly succeeded'
)
self
.
assertNotIn
(
'^'
,
err_msg
)
self
.
assertEqual
(
err_msg
,
'
%
r !=
%
r'
%
(
s1
,
s2
))
self
.
assertMultiLineEqual
(
s
+
'a'
,
s
+
'a'
)
def
testAssertIsNone
(
self
):
self
.
assertIsNone
(
None
)
self
.
assertRaises
(
self
.
failureException
,
self
.
assertIsNone
,
False
)
...
...
Lib/unittest.py
Dosyayı görüntüle @
935a5888
...
...
@@ -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
))
...
...
Misc/NEWS
Dosyayı görüntüle @
935a5888
...
...
@@ -61,6 +61,9 @@ Core and Builtins
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 #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