Add some additional tests that check more proxy behaviors.
This commit is contained in:
parent
2a908f6b7b
commit
5935ff07be
@ -1,5 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
import UserList
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
import test_support
|
import test_support
|
||||||
@ -149,6 +150,23 @@ class ReferencesTestCase(TestBase):
|
|||||||
o = C()
|
o = C()
|
||||||
self.check_proxy(o, weakref.proxy(o))
|
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):
|
def test_callable_proxy(self):
|
||||||
o = Callable()
|
o = Callable()
|
||||||
ref1 = weakref.proxy(o)
|
ref1 = weakref.proxy(o)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user