(self)
| 249 | await pool.close() |
| 250 | |
| 251 | async def test_pool_11(self): |
| 252 | pool = await self.create_pool(database='postgres', |
| 253 | init_size=1, min_size=1, max_size=1) |
| 254 | |
| 255 | async with pool.acquire() as con: |
| 256 | self.assertIn(repr(con._con), repr(con)) # Test __repr__. |
| 257 | |
| 258 | ps = await con.prepare('SELECT 1') |
| 259 | txn = con.transaction() |
| 260 | async with con.transaction(): |
| 261 | cur = await con.cursor('SELECT 1') |
| 262 | ps_cur = await ps.cursor() |
| 263 | |
| 264 | self.assertIn('[released]', repr(con)) |
| 265 | |
| 266 | with self.assertRaisesRegex( |
| 267 | asyncpg.InterfaceError, |
| 268 | r'cannot call Connection\.execute.*released back to the pool'): |
| 269 | |
| 270 | con.execute('select 1') |
| 271 | |
| 272 | for meth in ('fetchval', 'fetchrow', 'fetch', 'explain', |
| 273 | 'get_query', 'get_statusmsg', 'get_parameters', |
| 274 | 'get_attributes'): |
| 275 | with self.assertRaisesRegex( |
| 276 | asyncpg.InterfaceError, |
| 277 | r'cannot call PreparedStatement\.{meth}.*released ' |
| 278 | r'back to the pool'.format(meth=meth)): |
| 279 | |
| 280 | getattr(ps, meth)() |
| 281 | |
| 282 | for c in (cur, ps_cur): |
| 283 | for meth in ('fetch', 'fetchrow'): |
| 284 | with self.assertRaisesRegex( |
| 285 | asyncpg.InterfaceError, |
| 286 | r'cannot call Cursor\.{meth}.*released ' |
| 287 | r'back to the pool'.format(meth=meth)): |
| 288 | |
| 289 | getattr(c, meth)() |
| 290 | |
| 291 | with self.assertRaisesRegex( |
| 292 | asyncpg.InterfaceError, |
| 293 | r'cannot call Cursor\.forward.*released ' |
| 294 | r'back to the pool'): |
| 295 | |
| 296 | c.forward(1) |
| 297 | |
| 298 | for meth in ('start', 'commit', 'rollback'): |
| 299 | with self.assertRaisesRegex( |
| 300 | asyncpg.InterfaceError, |
| 301 | r'cannot call Transaction\.{meth}.*released ' |
| 302 | r'back to the pool'.format(meth=meth)): |
| 303 | |
| 304 | getattr(txn, meth)() |
| 305 | |
| 306 | await pool.close() |
| 307 | |
| 308 | async def test_pool_12(self): |
nothing calls this directly
no test coverage detected