Test that Connection.reset() closes any open transaction.
(self)
| 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.""" |
| 579 | async with self.create_pool(database='postgres', |
| 580 | init_size=1, |
| 581 | min_size=1, |
| 582 | max_size=1) as pool: |
| 583 | async def get_xact_id(con): |
| 584 | return await con.fetchval('select txid_current()') |
| 585 | |
| 586 | with self.assertLoopErrorHandlerCalled('an active transaction'): |
| 587 | async with pool.acquire() as con: |
| 588 | real_con = con._con # unwrap PoolConnectionProxy |
| 589 | |
| 590 | id1 = await get_xact_id(con) |
| 591 | |
| 592 | tr = con.transaction() |
| 593 | self.assertIsNone(con._con._top_xact) |
| 594 | await tr.start() |
| 595 | self.assertIs(real_con._top_xact, tr) |
| 596 | |
| 597 | id2 = await get_xact_id(con) |
| 598 | self.assertNotEqual(id1, id2) |
| 599 | |
| 600 | self.assertIsNone(real_con._top_xact) |
| 601 | |
| 602 | async with pool.acquire() as con: |
| 603 | self.assertIs(con._con, real_con) |
| 604 | self.assertIsNone(con._con._top_xact) |
| 605 | id3 = await get_xact_id(con) |
| 606 | self.assertNotEqual(id2, id3) |
| 607 | |
| 608 | async def test_pool_connection_methods(self): |
| 609 | async def test_fetch(pool): |
nothing calls this directly
no test coverage detected