(self)
| 546 | await con.fetchval('SELECT 1') |
| 547 | |
| 548 | async def test_pool_config_persistence(self): |
| 549 | N = 100 |
| 550 | cons = set() |
| 551 | |
| 552 | class MyConnection(asyncpg.Connection): |
| 553 | async def foo(self): |
| 554 | return 42 |
| 555 | |
| 556 | async def fetchval(self, query): |
| 557 | res = await super().fetchval(query) |
| 558 | return res + 1 |
| 559 | |
| 560 | async def test(pool): |
| 561 | async with pool.acquire() as con: |
| 562 | self.assertEqual(await con.fetchval('SELECT 1'), 2) |
| 563 | self.assertEqual(await con.foo(), 42) |
| 564 | self.assertTrue(isinstance(con, MyConnection)) |
| 565 | self.assertEqual(con._con._config.statement_cache_size, 3) |
| 566 | cons.add(con) |
| 567 | |
| 568 | async with self.create_pool( |
| 569 | database='postgres', init_size=10, min_size=1, max_size=10, |
| 570 | max_queries=1, connection_class=MyConnection, |
| 571 | statement_cache_size=3) as pool: |
| 572 | |
| 573 | await asyncio.gather(*[test(pool) for _ in range(N)]) |
| 574 | |
| 575 | self.assertEqual(len(cons), N) |
| 576 | |
| 577 | async def test_pool_release_in_xact(self): |
| 578 | """Test that Connection.reset() closes any open transaction.""" |
nothing calls this directly
no test coverage detected