summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-11-27 09:31:37 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-11-27 09:31:37 (GMT)
commit6e165b30de0120360f13d86652db4c528941269f (patch)
treeb68b64c195a1ea96b472274b286701c924221987 /Doc/library
parentdb213a297d5b7f4728c540b33f5e2a25b0596b23 (diff)
downloadcpython-6e165b30de0120360f13d86652db4c528941269f.zip
cpython-6e165b30de0120360f13d86652db4c528941269f.tar.gz
cpython-6e165b30de0120360f13d86652db4c528941269f.tar.bz2
Issue 10242: unittest.assertItemsEqual makes too many assumptions.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/unittest.rst20
1 files changed, 13 insertions, 7 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index f2c6dee..2236f72 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -1068,8 +1068,8 @@ Test cases
| :meth:`assertDictContainsSubset(a, b) | all the key/value pairs | 3.1 |
| <TestCase.assertDictContainsSubset>` | in `a` exist in `b` | |
+---------------------------------------+--------------------------------+--------------+
- | :meth:`assertItemsEqual(a, b) | `a` and `b` have the same | 3.2 |
- | <TestCase.assertItemsEqual>` | elements in the same number, | |
+ | :meth:`assertCountEqual(a, b) | `a` and `b` have the same | 3.2 |
+ | <TestCase.assertCountEqual>` | elements in the same number, | |
| | regardless of their order | |
+---------------------------------------+--------------------------------+--------------+
@@ -1130,7 +1130,7 @@ Test cases
.. versionadded:: 3.1
- .. method:: assertItemsEqual(actual, expected, msg=None)
+ .. method:: assertCountEqual(expected, actual, msg=None)
Test that sequence *expected* contains the same elements as *actual*,
regardless of their order. When they don't, an error message listing the
@@ -1138,12 +1138,18 @@ Test cases
Duplicate elements are *not* ignored when comparing *actual* and
*expected*. It verifies if each element has the same count in both
- sequences. It is the equivalent of ``assertEqual(sorted(expected),
- sorted(actual))`` but it works with sequences of unhashable objects as
- well.
+ sequences. Equivalent to:
+ ``assertEqual(Counter(iter(expected)), Counter(iter(actual)))``
+ but works with sequences of unhashable objects as well.
.. versionadded:: 3.2
+ .. method:: assertItemsEqual(actual, expected, msg=None)
+
+ Outdated name for :meth:`assertCountEqual`, kept for compatibility
+ with Python 2.7.
+
+ .. versionadded:: 3.2
.. method:: assertSameElements(actual, expected, msg=None)
@@ -1155,7 +1161,7 @@ Test cases
It is the equivalent of ``assertEqual(set(expected), set(actual))``
but it works with sequences of unhashable objects as well. Because
duplicates are ignored, this method has been deprecated in favour of
- :meth:`assertItemsEqual`.
+ :meth:`assertCountEqual`.
.. versionadded:: 3.1
.. deprecated:: 3.2