[Python-checkins] CVS: python/dist/src/Lib/test test_weakref.py,1.10,1.11
Fred L. Drake
fdrake@users.sourceforge.net
Thu, 06 Sep 2001 07:52:41 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv16477
Modified Files:
test_weakref.py
Log Message:
Added tests for key deletion for both Weak*Dictionary flavors.
This covers regression on SF bug #458860.
Index: test_weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_weakref.py 2001/08/03 04:11:27 1.10
--- test_weakref.py 2001/09/06 14:52:39 1.11
***************
*** 412,415 ****
--- 412,437 ----
{C(): 1, C(): 2, C(): 3})
+ def test_weak_keyed_delitem(self):
+ d = weakref.WeakKeyDictionary()
+ o1 = Object('1')
+ o2 = Object('2')
+ d[o1] = 'something'
+ d[o2] = 'something'
+ self.assert_(len(d) == 2)
+ del d[o1]
+ self.assert_(len(d) == 1)
+ self.assert_(d.keys() == [o2])
+
+ def test_weak_valued_delitem(self):
+ d = weakref.WeakValueDictionary()
+ o1 = Object('1')
+ o2 = Object('2')
+ d['something'] = o1
+ d['something else'] = o2
+ self.assert_(len(d) == 2)
+ del d['something']
+ self.assert_(len(d) == 1)
+ self.assert_(d.items() == [('something else', o2)])
+
run_unittest(ReferencesTestCase)