summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2008-09-04 01:42:51 (GMT)
committerBarry Warsaw <barry@python.org>2008-09-04 01:42:51 (GMT)
commitecaab837b6ef36edf1840afdba1fbab747c049d7 (patch)
tree948112c5a3f7dc5e1ee7bc8b473a737328db96ec /Lib/test/test_weakref.py
parent6ecc5c19802b994b3b7033953361f6157b4bdd0d (diff)
downloadcpython-ecaab837b6ef36edf1840afdba1fbab747c049d7.zip
cpython-ecaab837b6ef36edf1840afdba1fbab747c049d7.tar.gz
cpython-ecaab837b6ef36edf1840afdba1fbab747c049d7.tar.bz2
Committing the patch in issue 2965, so that weakref dicts have a closer
interface to normal dictionaries. keys(), values() and items() still return iterators instead of views, but that can be fixed later (or not).
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 1788ac5..108cd7f 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -790,8 +790,8 @@ class MappingTestCase(TestBase):
self.assertEqual(weakref.getweakrefcount(o), 1)
self.assert_(o is dict[o.arg],
"wrong object returned by weak dict!")
- items1 = dict.items()
- items2 = dict.copy().items()
+ items1 = list(dict.items())
+ items2 = list(dict.copy().items())
items1.sort()
items2.sort()
self.assertEqual(items1, items2,
@@ -856,8 +856,8 @@ class MappingTestCase(TestBase):
# Test iterkeyrefs()
objects2 = list(objects)
- self.assertEqual(len(list(dict.iterkeyrefs())), len(objects))
- for wr in dict.iterkeyrefs():
+ self.assertEqual(len(list(dict.keyrefs())), len(objects))
+ for wr in dict.keyrefs():
ob = wr()
self.assert_(ob in dict)
self.assert_(ob in dict)
@@ -892,28 +892,28 @@ class MappingTestCase(TestBase):
def check_iters(self, dict):
# item iterator:
- items = dict.items()
+ items = list(dict.items())
for item in dict.items():
items.remove(item)
- self.assert_(len(items) == 0, "items() did not touch all items")
+ self.assertFalse(items, "items() did not touch all items")
# key iterator, via __iter__():
keys = list(dict.keys())
for k in dict:
keys.remove(k)
- self.assert_(len(keys) == 0, "__iter__() did not touch all keys")
+ self.assertFalse(keys, "__iter__() did not touch all keys")
# key iterator, via iterkeys():
keys = list(dict.keys())
for k in dict.keys():
keys.remove(k)
- self.assert_(len(keys) == 0, "iterkeys() did not touch all keys")
+ self.assertFalse(keys, "iterkeys() did not touch all keys")
# value iterator:
values = list(dict.values())
for v in dict.values():
values.remove(v)
- self.assert_(len(values) == 0,
+ self.assertFalse(values,
"itervalues() did not touch all values")
def test_make_weak_keyed_dict_from_dict(self):
@@ -1030,7 +1030,7 @@ class MappingTestCase(TestBase):
self.assertEqual(len(d), 2)
del d[o1]
self.assertEqual(len(d), 1)
- self.assertEqual(d.keys(), [o2])
+ self.assertEqual(list(d.keys()), [o2])
def test_weak_valued_delitem(self):
d = weakref.WeakValueDictionary()
@@ -1041,7 +1041,7 @@ class MappingTestCase(TestBase):
self.assertEqual(len(d), 2)
del d['something']
self.assertEqual(len(d), 1)
- self.assert_(d.items() == [('something else', o2)])
+ self.assert_(list(d.items()) == [('something else', o2)])
def test_weak_keyed_bad_delitem(self):
d = weakref.WeakKeyDictionary()
@@ -1082,7 +1082,7 @@ class MappingTestCase(TestBase):
d[o] = o.value
del o # now the only strong references to keys are in objs
# Find the order in which iterkeys sees the keys.
- objs = d.keys()
+ objs = list(d.keys())
# Reverse it, so that the iteration implementation of __delitem__
# has to keep looping to find the first object we delete.
objs.reverse()