[Python-checkins] CVS: python/dist/src/Lib/test test_weakref.py,1.16,1.17
Fred L. Drake
fdrake@users.sourceforge.net
Wed, 19 Dec 2001 08:54:25 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv11361/Lib/test
Modified Files:
test_weakref.py
Log Message:
Add some additional tests that check more proxy behaviors.
Index: test_weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_weakref.py 2001/12/10 23:46:02 1.16
--- test_weakref.py 2001/12/19 16:54:23 1.17
***************
*** 1,4 ****
--- 1,5 ----
import sys
import unittest
+ import UserList
import weakref
***************
*** 149,152 ****
--- 150,170 ----
o = C()
self.check_proxy(o, weakref.proxy(o))
+
+ L = UserList.UserList()
+ p = weakref.proxy(L)
+ self.failIf(p, "proxy for empty UserList should be false")
+ p.append(12)
+ self.assertEqual(len(L), 1)
+ self.failUnless(p, "proxy for non-empty UserList should be true")
+ p[:] = [2, 3]
+ self.assertEqual(len(L), 2)
+ self.assertEqual(len(p), 2)
+ self.failUnless(3 in p, "proxy didn't support __contains__() properly")
+ p[1] = 5
+ self.assertEqual(L[1], 5)
+ self.assertEqual(p[1], 5)
+ L2 = UserList.UserList(L)
+ p2 = weakref.proxy(L2)
+ self.assertEqual(p, p2)
def test_callable_proxy(self):