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
c1d7c5b7
Kaydet (Commit)
c1d7c5b7
authored
Haz 05, 2010
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Tests for unittest.TestCase.maxDiff.
üst
d8918597
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
test_case.py
Lib/unittest/test/test_case.py
+39
-0
No files found.
Lib/unittest/test/test_case.py
Dosyayı görüntüle @
c1d7c5b7
...
...
@@ -596,6 +596,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
seq2
=
'b'
+
'x'
*
80
**
2
diff
=
'
\n
'
.
join
(
difflib
.
ndiff
(
pprint
.
pformat
(
seq1
)
.
splitlines
(),
pprint
.
pformat
(
seq2
)
.
splitlines
()))
# the +1 is the leading \n added by assertSequenceEqual
omitted
=
unittest
.
case
.
DIFF_OMITTED
%
(
len
(
diff
)
+
1
,)
self
.
maxDiff
=
len
(
diff
)
//
2
try
:
...
...
@@ -605,6 +607,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
else
:
self
.
fail
(
'assertSequenceEqual did not fail.'
)
self
.
assertTrue
(
len
(
msg
)
<
len
(
diff
))
self
.
assertIn
(
omitted
,
msg
)
self
.
maxDiff
=
len
(
diff
)
*
2
try
:
...
...
@@ -614,6 +617,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
else
:
self
.
fail
(
'assertSequenceEqual did not fail.'
)
self
.
assertTrue
(
len
(
msg
)
>
len
(
diff
))
self
.
assertNotIn
(
omitted
,
msg
)
self
.
maxDiff
=
None
try
:
...
...
@@ -623,6 +627,41 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
else
:
self
.
fail
(
'assertSequenceEqual did not fail.'
)
self
.
assertTrue
(
len
(
msg
)
>
len
(
diff
))
self
.
assertNotIn
(
omitted
,
msg
)
def
testTruncateMessage
(
self
):
self
.
maxDiff
=
1
message
=
self
.
_truncateMessage
(
'foo'
,
'bar'
)
omitted
=
unittest
.
case
.
DIFF_OMITTED
%
len
(
'bar'
)
self
.
assertEqual
(
message
,
'foo'
+
omitted
)
self
.
maxDiff
=
None
message
=
self
.
_truncateMessage
(
'foo'
,
'bar'
)
self
.
assertEqual
(
message
,
'foobar'
)
def
testAssertDictEqualTruncates
(
self
):
test
=
unittest
.
TestCase
(
'assertEqual'
)
def
truncate
(
msg
,
diff
):
return
'foo'
test
.
_truncateMessage
=
truncate
try
:
test
.
assertDictEqual
({},
{
1
:
0
})
except
self
.
failureException
as
e
:
self
.
assertEqual
(
str
(
e
),
'foo'
)
else
:
self
.
fail
(
'assertDictEqual did not fail'
)
def
testAssertMultiLineEqualTruncates
(
self
):
test
=
unittest
.
TestCase
(
'assertEqual'
)
def
truncate
(
msg
,
diff
):
return
'foo'
test
.
_truncateMessage
=
truncate
try
:
test
.
assertMultiLineEqual
(
'foo'
,
'bar'
)
except
self
.
failureException
as
e
:
self
.
assertEqual
(
str
(
e
),
'foo'
)
else
:
self
.
fail
(
'assertMultiLineEqual did not fail'
)
def
testAssertItemsEqual
(
self
):
a
=
object
()
...
...
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