(self)
| 335 | self.assertIsInstance(pool, asyncpg.pool.Pool) |
| 336 | |
| 337 | async def test_pool_exception_in_setup_and_init(self): |
| 338 | class Error(Exception): |
| 339 | pass |
| 340 | |
| 341 | async def setup(con): |
| 342 | nonlocal setup_calls, last_con |
| 343 | last_con = con |
| 344 | setup_calls += 1 |
| 345 | if setup_calls > 1: |
| 346 | cons.append(con) |
| 347 | else: |
| 348 | cons.append('error') |
| 349 | raise Error |
| 350 | |
| 351 | with self.subTest(method='setup'): |
| 352 | setup_calls = 0 |
| 353 | last_con = None |
| 354 | cons = [] |
| 355 | async with self.create_pool(database='postgres', |
| 356 | init_size=1, min_size=1, max_size=1, |
| 357 | setup=setup) as pool: |
| 358 | with self.assertRaises(Error): |
| 359 | await pool.acquire() |
| 360 | self.assertTrue(last_con.is_closed()) |
| 361 | |
| 362 | async with pool.acquire() as con: |
| 363 | self.assertEqual(cons, ['error', con]) |
| 364 | |
| 365 | with self.subTest(method='init'): |
| 366 | setup_calls = 0 |
| 367 | last_con = None |
| 368 | cons = [] |
| 369 | async with self.create_pool(database='postgres', |
| 370 | init_size=0, min_size=0, max_size=1, |
| 371 | init=setup) as pool: |
| 372 | with self.assertRaises(Error): |
| 373 | await pool.acquire() |
| 374 | self.assertTrue(last_con.is_closed()) |
| 375 | |
| 376 | async with pool.acquire() as con: |
| 377 | self.assertEqual(await con.fetchval('select 1::int'), 1) |
| 378 | self.assertEqual(cons, ['error', con._con]) |
| 379 | |
| 380 | async def test_pool_auth(self): |
| 381 | if not self.cluster.is_managed(): |
nothing calls this directly
no test coverage detected