diff options
author | Fred Drake <fdrake@acm.org> | 2001-12-19 16:54:23 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-12-19 16:54:23 (GMT) |
commit | 5935ff07beb0ed2b37dc7a85f04861122eaa5a9a (patch) | |
tree | 818c569c5786a09affb4c949efd6ccccef425a5c | |
parent | 2a908f6b7b4c1d8774374cb356cea369e3e072cf (diff) | |
download | cpython-5935ff07beb0ed2b37dc7a85f04861122eaa5a9a.zip cpython-5935ff07beb0ed2b37dc7a85f04861122eaa5a9a.tar.gz cpython-5935ff07beb0ed2b37dc7a85f04861122eaa5a9a.tar.bz2 |
Add some additional tests that check more proxy behaviors.
-rw-r--r-- | Lib/test/test_weakref.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 7f4870e..2ca6a7a 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -1,5 +1,6 @@ import sys import unittest +import UserList import weakref import test_support @@ -149,6 +150,23 @@ class ReferencesTestCase(TestBase): 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): o = Callable() ref1 = weakref.proxy(o) |