MCPcopy Index your code
hub / github.com/python/cpython / test_basic_proxy

Method test_basic_proxy

Lib/test/test_weakref.py:300–326  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

298 "proxy object w/out callback should have been re-used")
299
300 def test_basic_proxy(self):
301 o = C()
302 self.check_proxy(o, weakref.proxy(o))
303
304 L = collections.UserList()
305 p = weakref.proxy(L)
306 self.assertFalse(p, "proxy for empty UserList should be false")
307 p.append(12)
308 self.assertEqual(len(L), 1)
309 self.assertTrue(p, "proxy for non-empty UserList should be true")
310 p[:] = [2, 3]
311 self.assertEqual(len(L), 2)
312 self.assertEqual(len(p), 2)
313 self.assertIn(3, p, "proxy didn't support __contains__() properly")
314 p[1] = 5
315 self.assertEqual(L[1], 5)
316 self.assertEqual(p[1], 5)
317 L2 = collections.UserList(L)
318 p2 = weakref.proxy(L2)
319 self.assertEqual(p, p2)
320 ## self.assertEqual(repr(L2), repr(p2))
321 L3 = collections.UserList(range(10))
322 p3 = weakref.proxy(L3)
323 self.assertEqual(L3[:], p3[:])
324 self.assertEqual(L3[5:], p3[5:])
325 self.assertEqual(L3[:5], p3[:5])
326 self.assertEqual(L3[2:5], p3[2:5])
327
328 def test_proxy_unicode(self):
329 # See bug 5037

Callers

nothing calls this directly

Calls 8

check_proxyMethod · 0.95
proxyMethod · 0.80
assertFalseMethod · 0.80
assertTrueMethod · 0.80
assertInMethod · 0.80
CClass · 0.70
appendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected