Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 57bd00a

Browse files
committed
Adopt symmetric names for arguments (actual/expected --> first/second).
1 parent 1397ce1 commit 57bd00a

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

Doc/library/unittest.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,16 +1151,16 @@ Test cases
11511151
.. deprecated:: 3.2
11521152

11531153

1154-
.. method:: assertCountEqual(actual, expected, msg=None)
1154+
.. method:: assertCountEqual(first, second, msg=None)
11551155

1156-
Test that sequence *actual* contains the same elements as *expected*,
1156+
Test that sequence *first* contains the same elements as *second*,
11571157
regardless of their order. When they don't, an error message listing the
11581158
differences between the sequences will be generated.
11591159

1160-
Duplicate elements are *not* ignored when comparing *actual* and
1161-
*expected*. It verifies if each element has the same count in both
1160+
Duplicate elements are *not* ignored when comparing *first* and
1161+
*second*. It verifies whether each element has the same count in both
11621162
sequences. Equivalent to:
1163-
``assertEqual(Counter(list(actual)), Counter(list(expected)))``
1163+
``assertEqual(Counter(list(first)), Counter(list(second)))``
11641164
but works with sequences of unhashable objects as well.
11651165

11661166
.. versionadded:: 3.2

Lib/unittest/case.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,20 +1004,20 @@ def assertSameElements(self, expected_seq, actual_seq, msg=None):
10041004
self.fail(self._formatMessage(msg, standardMsg))
10051005

10061006

1007-
def assertCountEqual(self, actual, expected, msg=None):
1008-
"""An unordered sequence specific comparison. It asserts that
1009-
actual and expected have the same element counts.
1010-
Equivalent to::
1007+
def assertCountEqual(self, first, second, msg=None):
1008+
"""An unordered sequence comparison asserting that the same elements,
1009+
regardless of order. If the same element occurs more than once,
1010+
it verifies that the elements occur the same number of times.
10111011
1012-
self.assertEqual(Counter(list(actual)),
1013-
Counter(list(expected)))
1012+
self.assertEqual(Counter(list(first)),
1013+
Counter(list(second)))
10141014
1015-
Asserts that each element has the same count in both sequences.
1016-
Example:
1015+
Example:
10171016
- [0, 1, 1] and [1, 0, 1] compare equal.
10181017
- [0, 0, 1] and [0, 1] compare unequal.
1018+
10191019
"""
1020-
actual_seq, expected_seq = list(actual), list(expected)
1020+
actual_seq, expected_seq = list(first), list(second)
10211021
try:
10221022
actual = collections.Counter(actual_seq)
10231023
expected = collections.Counter(expected_seq)
@@ -1031,7 +1031,7 @@ def assertCountEqual(self, actual, expected, msg=None):
10311031

10321032
if differences:
10331033
standardMsg = 'Element counts were not equal:\n'
1034-
lines = ['Got %d, expected %d: %r' % diff for diff in differences]
1034+
lines = ['First has %d, Second has %d: %r' % diff for diff in differences]
10351035
diffMsg = '\n'.join(lines)
10361036
standardMsg = self._truncateMessage(standardMsg, diffMsg)
10371037
msg = self._formatMessage(msg, standardMsg)

0 commit comments

Comments
 (0)