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
57bd00a1
Kaydet (Commit)
57bd00a1
authored
Ara 24, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Adopt symmetric names for arguments (actual/expected --> first/second).
üst
1397ce18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
unittest.rst
Doc/library/unittest.rst
+5
-5
case.py
Lib/unittest/case.py
+10
-10
No files found.
Doc/library/unittest.rst
Dosyayı görüntüle @
57bd00a1
...
...
@@ -1151,16 +1151,16 @@ Test cases
.. deprecated:: 3.2
.. method:: assertCountEqual(
actual, expecte
d, msg=None)
.. method:: assertCountEqual(
first, secon
d, msg=None)
Test that sequence *
actual* contains the same elements as *expecte
d*,
Test that sequence *
first* contains the same elements as *secon
d*,
regardless of their order. When they don't, an error message listing the
differences between the sequences will be generated.
Duplicate elements are *not* ignored when comparing *
actual
* and
*
expected*. It verifies if
each element has the same count in both
Duplicate elements are *not* ignored when comparing *
first
* and
*
second*. It verifies whether
each element has the same count in both
sequences. Equivalent to:
``assertEqual(Counter(list(
actual)), Counter(list(expecte
d)))``
``assertEqual(Counter(list(
first)), Counter(list(secon
d)))``
but works with sequences of unhashable objects as well.
.. versionadded:: 3.2
...
...
Lib/unittest/case.py
Dosyayı görüntüle @
57bd00a1
...
...
@@ -1004,20 +1004,20 @@ class TestCase(object):
self
.
fail
(
self
.
_formatMessage
(
msg
,
standardMsg
))
def
assertCountEqual
(
self
,
actual
,
expecte
d
,
msg
=
None
):
"""An unordered sequence
specific comparison. It asserts that
actual and expected have the same element counts.
Equivalent to::
def
assertCountEqual
(
self
,
first
,
secon
d
,
msg
=
None
):
"""An unordered sequence
comparison asserting that the same elements,
regardless of order. If the same element occurs more than once,
it verifies that the elements occur the same number of times.
self.assertEqual(Counter(list(
actual
)),
Counter(list(
expecte
d)))
self.assertEqual(Counter(list(
first
)),
Counter(list(
secon
d)))
Asserts that each element has the same count in both sequences.
Example:
Example:
- [0, 1, 1] and [1, 0, 1] compare equal.
- [0, 0, 1] and [0, 1] compare unequal.
"""
actual_seq
,
expected_seq
=
list
(
actual
),
list
(
expecte
d
)
actual_seq
,
expected_seq
=
list
(
first
),
list
(
secon
d
)
try
:
actual
=
collections
.
Counter
(
actual_seq
)
expected
=
collections
.
Counter
(
expected_seq
)
...
...
@@ -1031,7 +1031,7 @@ class TestCase(object):
if
differences
:
standardMsg
=
'Element counts were not equal:
\n
'
lines
=
[
'
Got
%
d, expected
%
d:
%
r'
%
diff
for
diff
in
differences
]
lines
=
[
'
First has
%
d, Second has
%
d:
%
r'
%
diff
for
diff
in
differences
]
diffMsg
=
'
\n
'
.
join
(
lines
)
standardMsg
=
self
.
_truncateMessage
(
standardMsg
,
diffMsg
)
msg
=
self
.
_formatMessage
(
msg
,
standardMsg
)
...
...
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