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
0100702b
Kaydet (Commit)
0100702b
authored
Haz 05, 2010
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 8351. Suppress large diffs in unittest.TestCase.assertSequenceEqual.
üst
9ef5d330
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
case.py
Lib/unittest/case.py
+10
-3
test_case.py
Lib/unittest/test/test_case.py
+19
-0
No files found.
Lib/unittest/case.py
Dosyayı görüntüle @
0100702b
...
...
@@ -13,7 +13,7 @@ from .util import (
)
__unittest
=
True
TRUNCATED_DIFF
=
'
\n
[diff truncated...]'
class
SkipTest
(
Exception
):
"""
...
...
@@ -589,7 +589,8 @@ class TestCase(object):
failUnlessRaises
=
_deprecate
(
assertRaises
)
failIf
=
_deprecate
(
assertFalse
)
def
assertSequenceEqual
(
self
,
seq1
,
seq2
,
msg
=
None
,
seq_type
=
None
):
def
assertSequenceEqual
(
self
,
seq1
,
seq2
,
msg
=
None
,
seq_type
=
None
,
max_diff
=
80
*
8
):
"""An equality assertion for ordered sequences (like lists and tuples).
For the purposes of this function, a valid ordered sequence type is one
...
...
@@ -602,6 +603,7 @@ class TestCase(object):
datatype should be enforced.
msg: Optional message to use on failure instead of a list of
differences.
max_diff: Maximum size off the diff, larger diffs are not shown
"""
if
seq_type
is
not
None
:
seq_type_name
=
seq_type
.
__name__
...
...
@@ -684,9 +686,14 @@ class TestCase(object):
except
(
TypeError
,
IndexError
,
NotImplementedError
):
differing
+=
(
'Unable to index element
%
d '
'of second
%
s
\n
'
%
(
len1
,
seq_type_name
))
standardMsg
=
differing
+
'
\n
'
+
'
\n
'
.
join
(
standardMsg
=
differing
diffMsg
=
'
\n
'
+
'
\n
'
.
join
(
difflib
.
ndiff
(
pprint
.
pformat
(
seq1
)
.
splitlines
(),
pprint
.
pformat
(
seq2
)
.
splitlines
()))
if
max_diff
is
None
or
len
(
diffMsg
)
<=
max_diff
:
standardMsg
+=
diffMsg
else
:
standardMsg
+=
diffMsg
[:
max_diff
]
+
TRUNCATED_DIFF
msg
=
self
.
_formatMessage
(
msg
,
standardMsg
)
self
.
fail
(
msg
)
...
...
Lib/unittest/test/test_case.py
Dosyayı görüntüle @
0100702b
import
difflib
import
pprint
import
re
import
sys
...
...
@@ -588,6 +590,23 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self
.
assertRaises
(
self
.
failureException
,
self
.
assertDictEqual
,
[],
d
)
self
.
assertRaises
(
self
.
failureException
,
self
.
assertDictEqual
,
1
,
1
)
def
testAssertSequenceEqualMaxDiff
(
self
):
seq1
=
'a'
+
'x'
*
80
**
2
seq2
=
'b'
+
'x'
*
80
**
2
diff
=
'
\n
'
.
join
(
difflib
.
ndiff
(
pprint
.
pformat
(
seq1
)
.
splitlines
(),
pprint
.
pformat
(
seq2
)
.
splitlines
()))
try
:
self
.
assertSequenceEqual
(
seq1
,
seq2
,
max_diff
=
len
(
diff
)
/
2
)
except
AssertionError
as
e
:
msg
=
e
.
args
[
0
]
self
.
assertTrue
(
len
(
msg
)
<
len
(
diff
))
try
:
self
.
assertSequenceEqual
(
seq1
,
seq2
,
max_diff
=
len
(
diff
)
*
2
)
except
AssertionError
as
e
:
msg
=
e
.
args
[
0
]
self
.
assertTrue
(
len
(
msg
)
>
len
(
diff
))
def
testAssertItemsEqual
(
self
):
a
=
object
()
self
.
assertItemsEqual
([
1
,
2
,
3
],
[
3
,
2
,
1
])
...
...
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