From f2a62c37a66fe668031637fe619d0f94a941eb3f Mon Sep 17 00:00:00 2001 From: "Michael W. Hudson" Date: Fri, 23 Aug 2002 16:29:27 +0000 Subject: [PATCH] backport gvanrossum's checkin of revision 1.19 of test_weakref.py MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 2ca6a7adb792..089190845fbe 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -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)) -- 2.47.3