mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-94808: cover PyMapping_HasKeyString
and PyMapping_HasKey
(#98486)
This commit is contained in:
parent
216f45e4fe
commit
5d30544485
2 changed files with 48 additions and 0 deletions
|
@ -404,6 +404,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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue