(self)
| 487 | await con.fetchval('SELECT 1') |
| 488 | |
| 489 | async def test_pool_config_persistence(self): |
| 490 | N = 100 |
| 491 | cons = set() |
| 492 | |
| 493 | class MyConnection(asyncpg.Connection): |
| 494 | async def foo(self): |
| 495 | return 42 |
| 496 | |
| 497 | async def fetchval(self, query): |
| 498 | res = await super().fetchval(query) |
| 499 | return res + 1 |
| 500 | |
| 501 | async def test(pool): |
| 502 | async with pool.acquire() as con: |
| 503 | self.assertEqual(await con.fetchval('SELECT 1'), 2) |
| 504 | self.assertEqual(await con.foo(), 42) |
| 505 | self.assertTrue(isinstance(con, MyConnection)) |
| 506 | self.assertEqual(con._con._config.statement_cache_size, 3) |
| 507 | cons.add(con) |
| 508 | |
| 509 | async with self.create_pool( |
| 510 | database='postgres', min_size=10, max_size=10, |
| 511 | max_queries=1, connection_class=MyConnection, |
| 512 | statement_cache_size=3) as pool: |
| 513 | |
| 514 | await asyncio.gather(*[test(pool) for _ in range(N)]) |
| 515 | |
| 516 | self.assertEqual(len(cons), N) |
| 517 | |
| 518 | async def test_pool_release_in_xact(self): |
| 519 | """Test that Connection.reset() closes any open transaction.""" |
nothing calls this directly
no test coverage detected