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

Method test_proxy_repr

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

Source from the content-addressed store, hash-verified

232
233 @support.cpython_only
234 def test_proxy_repr(self):
235 obj = C()
236 ref = weakref.proxy(obj, self.callback)
237 regex = (
238 rf"<weakproxy at 0x[0-9a-fA-F]+; "
239 rf"to '{'' if __name__ == '__main__' else C.__module__ + '.'}{C.__qualname__}' "
240 rf"at 0x[0-9a-fA-F]+>"
241 )
242 self.assertRegex(repr(ref), regex)
243
244 obj = None
245 gc_collect()
246 self.assertRegex(repr(ref),
247 rf'<weakproxy at 0x[0-9a-fA-F]+; dead>')
248
249 def check_basic_ref(self, factory):
250 o = factory()

Callers

nothing calls this directly

Calls 4

gc_collectFunction · 0.90
proxyMethod · 0.80
assertRegexMethod · 0.80
CClass · 0.70

Tested by

no test coverage detected