(self)
| 432 | |
| 433 | @tb.with_connection_options(statement_cache_size=0) |
| 434 | async def test_prepare_23_no_stmt_cache_seq(self): |
| 435 | self.assertEqual(self.con._stmt_cache.get_max_size(), 0) |
| 436 | |
| 437 | async def check_simple(): |
| 438 | # Run a simple query a few times. |
| 439 | self.assertEqual(await self.con.fetchval('SELECT 1'), 1) |
| 440 | self.assertEqual(await self.con.fetchval('SELECT 2'), 2) |
| 441 | self.assertEqual(await self.con.fetchval('SELECT 1'), 1) |
| 442 | |
| 443 | await check_simple() |
| 444 | |
| 445 | # Run a query that timeouts. |
| 446 | with self.assertRaises(asyncio.TimeoutError): |
| 447 | await self.con.fetchrow('select pg_sleep(10)', timeout=0.02) |
| 448 | |
| 449 | # Check that we can run new queries after a timeout. |
| 450 | await check_simple() |
| 451 | |
| 452 | # Try a cursor/timeout combination. Cursors should always use |
| 453 | # named prepared statements. |
| 454 | async with self.con.transaction(): |
| 455 | with self.assertRaises(asyncio.TimeoutError): |
| 456 | async for _ in self.con.cursor( # NOQA |
| 457 | 'select pg_sleep(10)', timeout=0.1): |
| 458 | pass |
| 459 | |
| 460 | # Check that we can run queries after a failed cursor |
| 461 | # operation. |
| 462 | await check_simple() |
| 463 | |
| 464 | @tb.with_connection_options(max_cached_statement_lifetime=142) |
| 465 | async def test_prepare_24_max_lifetime(self): |
nothing calls this directly
no test coverage detected