summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-08-18 22:13:04 (GMT)
committerGuido van Rossum <guido@python.org>2006-08-18 22:13:04 (GMT)
commite2b70bcf7401477936fba99a8bf4a1f759ecc8a3 (patch)
tree4c9b65b7fd8c26a3d2f1b64ecd6b4c72a756b4b2 /Lib/test/test_weakref.py
parentd2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 (diff)
downloadcpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.zip
cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.tar.gz
cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 1f65010..a4fb7f3 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -739,7 +739,7 @@ class MappingTestCase(TestBase):
def test_weak_keys(self):
#
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
- # len(d), d.has_key().
+ # len(d), k in d.
#
dict, objects = self.make_weak_keyed_dict()
for o in objects:
@@ -761,8 +761,8 @@ class MappingTestCase(TestBase):
"deleting the keys did not clear the dictionary")
o = Object(42)
dict[o] = "What is the meaning of the universe?"
- self.assert_(dict.has_key(o))
- self.assert_(not dict.has_key(34))
+ self.assert_(o in dict)
+ self.assert_(34 not in dict)
def test_weak_keyed_iters(self):
dict, objects = self.make_weak_keyed_dict()
@@ -774,7 +774,7 @@ class MappingTestCase(TestBase):
objects2 = list(objects)
for wr in refs:
ob = wr()
- self.assert_(dict.has_key(ob))
+ self.assert_(ob in dict)
self.assert_(ob in dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
@@ -785,7 +785,7 @@ class MappingTestCase(TestBase):
self.assertEqual(len(list(dict.iterkeyrefs())), len(objects))
for wr in dict.iterkeyrefs():
ob = wr()
- self.assert_(dict.has_key(ob))
+ self.assert_(ob in dict)
self.assert_(ob in dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
@@ -900,13 +900,13 @@ class MappingTestCase(TestBase):
weakdict = klass()
o = weakdict.setdefault(key, value1)
self.assert_(o is value1)
- self.assert_(weakdict.has_key(key))
+ self.assert_(key in weakdict)
self.assert_(weakdict.get(key) is value1)
self.assert_(weakdict[key] is value1)
o = weakdict.setdefault(key, value2)
self.assert_(o is value1)
- self.assert_(weakdict.has_key(key))
+ self.assert_(key in weakdict)
self.assert_(weakdict.get(key) is value1)
self.assert_(weakdict[key] is value1)
@@ -920,20 +920,20 @@ class MappingTestCase(TestBase):
def check_update(self, klass, dict):
#
- # This exercises d.update(), len(d), d.keys(), d.has_key(),
+ # This exercises d.update(), len(d), d.keys(), k in d,
# d.get(), d[].
#
weakdict = klass()
weakdict.update(dict)
self.assert_(len(weakdict) == len(dict))
for k in weakdict.keys():
- self.assert_(dict.has_key(k),
+ self.assert_(k in dict,
"mysterious new key appeared in weak dict")
v = dict.get(k)
self.assert_(v is weakdict[k])
self.assert_(v is weakdict.get(k))
for k in dict.keys():
- self.assert_(weakdict.has_key(k),
+ self.assert_(k in weakdict,
"original key disappeared in weak dict")
v = dict[k]
self.assert_(v is weakdict[k])