]> granicus.if.org Git - python/commitdiff
Deprecate assertDictContainsSubset()
authorRaymond Hettinger <python@rcn.com>
Tue, 21 Dec 2010 19:24:26 +0000 (19:24 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 21 Dec 2010 19:24:26 +0000 (19:24 +0000)
Doc/library/unittest.rst
Lib/unittest/case.py
Lib/unittest/test/test_case.py
Misc/NEWS

index 9d0d90ac0a1a07e33984bbf7d0e89fba0be024a5..9c0f1a1d0d9feb0a78257f975b123ff11501eae9 100644 (file)
@@ -1078,9 +1078,6 @@ Test cases
    | :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 @@ Test cases
       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)
index b02d475c5d588b406ec2312222d7400c097a315e..15c7eee8e2c4cd34596dcabe21951c8a73a46c5d 100644 (file)
@@ -934,6 +934,8 @@ class TestCase(object):
 
     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():
index 3ad883d8279072a93c5bbd35c28b9e86750f4da1..3376428c6a9382bb40ba5169fd955f7cf4be8435 100644 (file)
@@ -1079,6 +1079,7 @@ test case
             (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 @@ test case
         deprecated_names = [
             'failIfEqual', 'failUnlessEqual', 'failUnlessAlmostEqual',
             'failIfAlmostEqual', 'failUnless', 'failUnlessRaises', 'failIf',
-            'assertSameElements'
+            'assertSameElements', 'assertDictContainsSubset',
         ]
         for deprecated_name in deprecated_names:
             with self.assertRaises(AttributeError):
index 1a49d3ed81f82bc0c1b4f119024187b7006fa082..ea4e52d27f41b695a754d18e7b21cd19fb7dca36 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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?
 ================================