summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-12-24 21:51:48 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-12-24 21:51:48 (GMT)
commit57bd00a15bc06d90a1d8540706b3a66ee8c69039 (patch)
treee0c90291ae66b73398d2b729b603d19c55830ddf
parent1397ce1821d4888a3637bd9490cc9c930f3c7b98 (diff)
downloadcpython-57bd00a15bc06d90a1d8540706b3a66ee8c69039.zip
cpython-57bd00a15bc06d90a1d8540706b3a66ee8c69039.tar.gz
cpython-57bd00a15bc06d90a1d8540706b3a66ee8c69039.tar.bz2
Adopt symmetric names for arguments (actual/expected --> first/second).
-rw-r--r--Doc/library/unittest.rst10
-rw-r--r--Lib/unittest/case.py20
2 files changed, 15 insertions, 15 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 9e30908..609789f 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -1151,16 +1151,16 @@ Test cases
.. deprecated:: 3.2
- .. method:: assertCountEqual(actual, expected, msg=None)
+ .. method:: assertCountEqual(first, second, msg=None)
- Test that sequence *actual* contains the same elements as *expected*,
+ Test that sequence *first* contains the same elements as *second*,
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(expected)))``
+ ``assertEqual(Counter(list(first)), Counter(list(second)))``
but works with sequences of unhashable objects as well.
.. versionadded:: 3.2
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 82b139f..004a9f5 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -1004,20 +1004,20 @@ class TestCase(object):
self.fail(self._formatMessage(msg, standardMsg))
- def assertCountEqual(self, actual, expected, msg=None):
- """An unordered sequence specific comparison. It asserts that
- actual and expected have the same element counts.
- Equivalent to::
+ def assertCountEqual(self, first, second, 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(expected)))
+ self.assertEqual(Counter(list(first)),
+ Counter(list(second)))
- 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(expected)
+ actual_seq, expected_seq = list(first), list(second)
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)