[Python-checkins] CVS: python/dist/src/Lib/test test_weakref.py,1.14,1.15
Fred L. Drake
fdrake@users.sourceforge.net
Tue, 06 Nov 2001 08:38:36 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv15487/test
Modified Files:
test_weakref.py
Log Message:
Add a regression test for SF bug #478536: If a value cannot be weakly
referenced, WeakKeyDictionary.has_key() should return 0 instead of raising
TypeError.
Index: test_weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** test_weakref.py 2001/10/18 19:28:29 1.14
--- test_weakref.py 2001/11/06 16:38:34 1.15
***************
*** 273,277 ****
#
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
! # len(d).
#
dict, objects = self.make_weak_keyed_dict()
--- 273,277 ----
#
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
! # len(d), d.has_key().
#
dict, objects = self.make_weak_keyed_dict()
***************
*** 295,298 ****
--- 295,302 ----
self.assert_(len(dict) == 0,
"deleting the keys did not clear the dictionary")
+ o = Object(42)
+ dict[o] = "What is the meaning of the universe?"
+ self.assert_(dict.has_key(o))
+ self.assert_(not dict.has_key(34))
def test_weak_keyed_iters(self):