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:
Guido van Rossum 2006-08-18 22:13:04 +00:00
parent d2dbecb4ae
commit e2b70bcf74
93 changed files with 215 additions and 313 deletions

View file

@ -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))