(self)
| 2824 | class 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() |
no test coverage detected