diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-10-26 04:57:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 04:57:49 (GMT) |
commit | db14a9d594e9d73b293916d6e52065a2d91f1c1f (patch) | |
tree | ec27d514203c8e6212aa550224b566e0485756d8 /Lib | |
parent | 2aedba59ecc7e89479226f0013c1771c4ef66413 (diff) | |
download | cpython-db14a9d594e9d73b293916d6e52065a2d91f1c1f.zip cpython-db14a9d594e9d73b293916d6e52065a2d91f1c1f.tar.gz cpython-db14a9d594e9d73b293916d6e52065a2d91f1c1f.tar.bz2 |
gh-94808: cover `PyMapping_HasKeyString` and `PyMapping_HasKey` (GH-98486)
(cherry picked from commit 5d30544485dc56ab999ad7656ef6559306fd013f)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_capi.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index d5012a7..a4d643f 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -403,6 +403,18 @@ class CAPITest(unittest.TestCase): self.assertRaises(TypeError, _testcapi.get_mapping_values, bad_mapping) self.assertRaises(TypeError, _testcapi.get_mapping_items, bad_mapping) + def test_mapping_has_key(self): + dct = {'a': 1} + self.assertTrue(_testcapi.mapping_has_key(dct, 'a')) + self.assertFalse(_testcapi.mapping_has_key(dct, 'b')) + + class SubDict(dict): + pass + + dct2 = SubDict({'a': 1}) + self.assertTrue(_testcapi.mapping_has_key(dct2, 'a')) + self.assertFalse(_testcapi.mapping_has_key(dct2, 'b')) + @unittest.skipUnless(hasattr(_testcapi, 'negative_refcount'), 'need _testcapi.negative_refcount') def test_negative_refcount(self): |