mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Get rid of dict.has_key(). Boy this has a lot of repercussions!
Not all code has been fixed yet; this is just a checkpoint... The C API still has PyDict_HasKey() and _HasKeyString(); not sure if I want to change those just yet.
This commit is contained in:
parent
d2dbecb4ae
commit
e2b70bcf74
93 changed files with 215 additions and 313 deletions
|
@ -54,12 +54,10 @@ class BasicTestMappingProtocol(unittest.TestCase):
|
|||
#len
|
||||
self.assertEqual(len(p), 0)
|
||||
self.assertEqual(len(d), len(self.reference))
|
||||
#has_key
|
||||
#__contains__
|
||||
for k in self.reference:
|
||||
self.assert_(d.has_key(k))
|
||||
self.assert_(k in d)
|
||||
for k in self.other:
|
||||
self.failIf(d.has_key(k))
|
||||
self.failIf(k in d)
|
||||
#cmp
|
||||
self.assertEqual(cmp(p,p), 0)
|
||||
|
@ -333,16 +331,6 @@ class TestMappingProtocol(BasicTestMappingProtocol):
|
|||
d = self._full_mapping({1:2})
|
||||
self.assertEqual(d.items(), [(1, 2)])
|
||||
|
||||
def test_has_key(self):
|
||||
d = self._empty_mapping()
|
||||
self.assert_(not d.has_key('a'))
|
||||
d = self._full_mapping({'a': 1, 'b': 2})
|
||||
k = d.keys()
|
||||
k.sort()
|
||||
self.assertEqual(k, ['a', 'b'])
|
||||
|
||||
self.assertRaises(TypeError, d.has_key)
|
||||
|
||||
def test_contains(self):
|
||||
d = self._empty_mapping()
|
||||
self.assert_(not ('a' in d))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue