diff options
-rw-r--r-- | Lib/unittest/case.py | 3 | ||||
-rw-r--r-- | Lib/unittest/test/test_case.py | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-06-02-16-39-42.bpo-44295.erg01m.rst | 2 |
3 files changed, 8 insertions, 1 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 607c7ae..61003d0 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -1146,7 +1146,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) + DeprecationWarning, + stacklevel=2) missing = [] mismatched = [] for key, value in subset.items(): diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index 3533485..442651e 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -706,6 +706,10 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing): with self.assertRaises(self.failureException): self.assertDictContainsSubset({'foo': one}, {'foo': '\uFFFD'}) + with self.assertWarns(DeprecationWarning) as warninfo: + self.assertDictContainsSubset({}, {}) + self.assertEqual(warninfo.warnings[0].filename, __file__) + def testAssertEqual(self): equal_pairs = [ ((), ()), diff --git a/Misc/NEWS.d/next/Library/2021-06-02-16-39-42.bpo-44295.erg01m.rst b/Misc/NEWS.d/next/Library/2021-06-02-16-39-42.bpo-44295.erg01m.rst new file mode 100644 index 0000000..86501c1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-06-02-16-39-42.bpo-44295.erg01m.rst @@ -0,0 +1,2 @@ +Ensure deprecation warning from :func:`assertDictContainsSubset` points at +calling code - by Anthony Sottile. |