MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_basic_proxy

Method test_basic_proxy

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

check_proxyMethod · 0.95
lenFunction · 0.85
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