[Python-checkins] r87424 - in python/branches/py3k: Doc/library/unittest.rst Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/NEWS
raymond.hettinger
python-checkins at python.org
Tue Dec 21 20:24:26 CET 2010
Author: raymond.hettinger
Date: Tue Dec 21 20:24:26 2010
New Revision: 87424
Log:
Deprecate assertDictContainsSubset()
Modified:
python/branches/py3k/Doc/library/unittest.rst
python/branches/py3k/Lib/unittest/case.py
python/branches/py3k/Lib/unittest/test/test_case.py
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Doc/library/unittest.rst
==============================================================================
--- python/branches/py3k/Doc/library/unittest.rst (original)
+++ python/branches/py3k/Doc/library/unittest.rst Tue Dec 21 20:24:26 2010
@@ -1078,9 +1078,6 @@
| :meth:`assertNotRegex(s, re) | ``not regex.search(s)`` | 3.2 |
| <TestCase.assertNotRegex>` | | |
+---------------------------------------+--------------------------------+--------------+
- | :meth:`assertDictContainsSubset(a, b) | all the key/value pairs | 3.1 |
- | <TestCase.assertDictContainsSubset>` | in `a` exist in `b` | |
- +---------------------------------------+--------------------------------+--------------+
| :meth:`assertCountEqual(a, b) | `a` and `b` have the same | 3.2 |
| <TestCase.assertCountEqual>` | elements in the same number, | |
| | regardless of their order | |
@@ -1145,7 +1142,13 @@
those in *subset*. If not, an error message listing the missing keys
and mismatched values is generated.
+ Note, the arguments are in the opposite order of what the method name
+ dictates. Instead, consider using the set-methods on :ref:`dictionary
+ views <dict-views>`, for example: ``d.keys() <= e.keys()`` or
+ ``d.items() <= d.items()``.
+
.. versionadded:: 3.1
+ .. deprecated:: 3.2
.. method:: assertCountEqual(actual, expected, msg=None)
Modified: python/branches/py3k/Lib/unittest/case.py
==============================================================================
--- python/branches/py3k/Lib/unittest/case.py (original)
+++ python/branches/py3k/Lib/unittest/case.py Tue Dec 21 20:24:26 2010
@@ -934,6 +934,8 @@
def assertDictContainsSubset(self, subset, dictionary, msg=None):
"""Checks whether dictionary is a superset of subset."""
+ warnings.warn('assertDictContainsSubset is deprecated',
+ DeprecationWarning)
missing = []
mismatched = []
for key, value in subset.items():
Modified: python/branches/py3k/Lib/unittest/test/test_case.py
==============================================================================
--- python/branches/py3k/Lib/unittest/test/test_case.py (original)
+++ python/branches/py3k/Lib/unittest/test/test_case.py Tue Dec 21 20:24:26 2010
@@ -1079,6 +1079,7 @@
(self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')),
(self.failIf, (False,)),
(self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3])),
+ (self.assertDictContainsSubset, (dict(a=1, b=2), dict(a=1, b=2, c=3))),
(self.assertRaisesRegexp, (KeyError, 'foo', lambda: {}['foo'])),
(self.assertRegexpMatches, ('bar', 'bar')),
)
@@ -1093,7 +1094,7 @@
deprecated_names = [
'failIfEqual', 'failUnlessEqual', 'failUnlessAlmostEqual',
'failIfAlmostEqual', 'failUnless', 'failUnlessRaises', 'failIf',
- 'assertSameElements'
+ 'assertSameElements', 'assertDictContainsSubset',
]
for deprecated_name in deprecated_names:
with self.assertRaises(AttributeError):
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Dec 21 20:24:26 2010
@@ -2,6 +2,18 @@
Python News
+++++++++++
+What's New in Python 3.2 Release Candidate 1
+============================================
+
+Core and Builtins
+-----------------
+
+Library
+-------
+
+- Deprecated assertDictContainsSubclass() in the unittest module.
+
+
What's New in Python 3.2 Beta 2?
================================
More information about the Python-checkins
mailing list