MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / test_timeout_06

Method test_timeout_06

tests/test_timeout.py:77–113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

75 self.assertEqual(await self.con.fetch('SELECT 1'), [(1,)])
76
77 async def test_timeout_06(self):
78 async with self.con.transaction():
79 with self.assertRaises(asyncio.TimeoutError), \
80 self.assertRunUnder(MAX_RUNTIME):
81 async for _ in self.con.cursor( # NOQA
82 'select pg_sleep(10)', timeout=0.1):
83 pass
84 self.assertEqual(await self.con.fetch('select 1'), [(1,)])
85
86 async with self.con.transaction():
87 cur = await self.con.cursor('select pg_sleep(10)')
88 with self.assertRaises(asyncio.TimeoutError), \
89 self.assertRunUnder(MAX_RUNTIME):
90 await cur.fetch(1, timeout=0.1)
91
92 async with self.con.transaction():
93 cur = await self.con.cursor('select pg_sleep(10)')
94 with self.assertRaises(asyncio.TimeoutError), \
95 self.assertRunUnder(MAX_RUNTIME):
96 await cur.forward(1, timeout=1e-10)
97
98 async with self.con.transaction():
99 cur = await self.con.cursor('select pg_sleep(10)')
100 with self.assertRaises(asyncio.TimeoutError), \
101 self.assertRunUnder(MAX_RUNTIME):
102 await cur.fetchrow(timeout=0.1)
103
104 async with self.con.transaction():
105 cur = await self.con.cursor('select pg_sleep(10)')
106 with self.assertRaises(asyncio.TimeoutError), \
107 self.assertRunUnder(MAX_RUNTIME):
108 await cur.fetchrow(timeout=0.1)
109
110 with self.assertRaises(asyncpg.InFailedSQLTransactionError):
111 await cur.fetch(1)
112
113 self.assertEqual(await self.con.fetch('select 1'), [(1,)])
114
115 async def test_invalid_timeout(self):
116 for command_timeout in ('a', False, -1):

Callers

nothing calls this directly

Calls 6

transactionMethod · 0.80
assertRunUnderMethod · 0.80
forwardMethod · 0.80
cursorMethod · 0.45
fetchMethod · 0.45
fetchrowMethod · 0.45

Tested by

no test coverage detected