File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
2
import unittest
3
+ import UserList
3
4
import weakref
4
5
5
6
import test_support
@@ -149,6 +150,23 @@ def test_basic_proxy(self):
149
150
o = C ()
150
151
self .check_proxy (o , weakref .proxy (o ))
151
152
153
+ L = UserList .UserList ()
154
+ p = weakref .proxy (L )
155
+ self .failIf (p , "proxy for empty UserList should be false" )
156
+ p .append (12 )
157
+ self .assertEqual (len (L ), 1 )
158
+ self .failUnless (p , "proxy for non-empty UserList should be true" )
159
+ p [:] = [2 , 3 ]
160
+ self .assertEqual (len (L ), 2 )
161
+ self .assertEqual (len (p ), 2 )
162
+ self .failUnless (3 in p , "proxy didn't support __contains__() properly" )
163
+ p [1 ] = 5
164
+ self .assertEqual (L [1 ], 5 )
165
+ self .assertEqual (p [1 ], 5 )
166
+ L2 = UserList .UserList (L )
167
+ p2 = weakref .proxy (L2 )
168
+ self .assertEqual (p , p2 )
169
+
152
170
def test_callable_proxy (self ):
153
171
o = Callable ()
154
172
ref1 = weakref .proxy (o )
You can’t perform that action at this time.
0 commit comments