@@ -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