values.remove(v)
self.assert_(len(values) == 0, "itervalues() did not touch all values")
+ def test_make_weak_keyed_dict_from_dict(self):
+ o = Object(3)
+ dict = weakref.WeakKeyDictionary({o:364})
+ self.assert_(dict[o] == 364)
+
+ def test_make_weak_keyed_dict_from_weak_keyed_dict(self):
+ o = Object(3)
+ dict = weakref.WeakKeyDictionary({o:364})
+ dict2 = weakref.WeakKeyDictionary(dict)
+ self.assert_(dict[o] == 364)
+
def make_weak_keyed_dict(self):
dict = weakref.WeakKeyDictionary()
objects = map(Object, range(self.COUNT))
def __init__(self, dict=None):
self.data = {}
- if dict is not None: self.update(dict)
def remove(k, selfref=ref(self)):
self = selfref()
if self is not None:
del self.data[k]
self._remove = remove
+ if dict is not None: self.update(dict)
def __delitem__(self, key):
for ref in self.data.iterkeys():