diff Lib/test/test_weakref.py @ 24995:86aa2c2da40e 2.2

backport gvanrossum's checkin of revision 1.19 of test_weakref.py SF patch 564549 (Erik Andersén). The WeakKeyDictionary constructor didn't work when a dict arg was given. Fixed by moving a line. Also adding a unit test. Bugfix candidate.
author Michael W. Hudson <mwh@python.net>
date Fri, 23 Aug 2002 16:29:27 +0000
parents 2d376d926da8
children bd349999cb08
line wrap: on
line diff
--- a/Lib/test/test_weakref.py	Fri Aug 23 16:29:01 2002 +0000
+++ b/Lib/test/test_weakref.py	Fri Aug 23 16:29:27 2002 +0000
@@ -375,6 +375,17 @@
             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))