]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport gvanrossum's checkin of
authorMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:29:27 +0000 (16:29 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:29:27 +0000 (16:29 +0000)
    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.

Lib/test/test_weakref.py

index 2ca6a7adb7926aca5b5c9bc63beb466dc135fdbd..089190845fbea6f4f5440b955e9abfd77fb45c55 100644 (file)
@@ -375,6 +375,17 @@ class MappingTestCase(TestBase):
             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))