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

Method test_getbuffer_gc_collect

Lib/test/test_io/test_memoryio.py:488–505  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

486 memio.write(b'x')
487
488 def test_getbuffer_gc_collect(self):
489 memio = self.ioclass(b"1234567890")
490 buf = memio.getbuffer()
491 memiowr = weakref.ref(memio)
492 bufwr = weakref.ref(buf)
493 # Create a reference loop.
494 a = [buf]
495 a.append(a)
496 # The Python implementation emits an unraisable exception.
497 with support.catch_unraisable_exception():
498 del memio
499 del buf
500 del a
501 # The C implementation emits an unraisable exception.
502 with support.catch_unraisable_exception():
503 gc.collect()
504 self.assertIsNone(memiowr())
505 self.assertIsNone(bufwr())
506
507 def test_read1(self):
508 buf = self.buftype("1234567890")

Callers

nothing calls this directly

Calls 5

assertIsNoneMethod · 0.80
ioclassMethod · 0.45
getbufferMethod · 0.45
appendMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected