MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / _run_no_explicit_close_test

Method _run_no_explicit_close_test

tests/test_connect.py:2826–2847  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2824class TestConnectionGC(tb.ClusterTestCase):
2825
2826 async def _run_no_explicit_close_test(self):
2827 gc_was_enabled = gc.isenabled()
2828 gc.disable()
2829 try:
2830 con = await self.connect()
2831 await con.fetchval("select 123")
2832 proto = con._protocol
2833 conref = weakref.ref(con)
2834 del con
2835
2836 self.assertIsNone(conref())
2837 self.assertTrue(proto.is_closed())
2838
2839 # tick event loop; asyncio.selector_events._SelectorSocketTransport
2840 # needs a chance to close itself and remove its reference to proto
2841 await asyncio.sleep(0)
2842 protoref = weakref.ref(proto)
2843 del proto
2844 self.assertIsNone(protoref())
2845 finally:
2846 if gc_was_enabled:
2847 gc.enable()
2848
2849 async def test_no_explicit_close_no_debug(self):
2850 olddebug = self.loop.get_debug()

Calls 3

is_closedMethod · 0.80
connectMethod · 0.45
fetchvalMethod · 0.45

Tested by

no test coverage detected