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

Method test_cursor_iterable_02

tests/test_cursor.py:31–49  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

29 'result != expected for prefetch={}'.format(prefetch))
30
31 async def test_cursor_iterable_02(self):
32 # Test that it's not possible to create a cursor without hold
33 # outside of a transaction
34 s = await self.con.prepare(
35 'DECLARE t BINARY CURSOR WITHOUT HOLD FOR SELECT 1')
36 with self.assertRaises(asyncpg.NoActiveSQLTransactionError):
37 await s.fetch()
38
39 # Now test that statement.cursor() does not let you
40 # iterate over it outside of a transaction
41 st = await self.con.prepare('SELECT generate_series(0, 20)')
42
43 it = st.cursor(prefetch=5).__aiter__()
44 if inspect.isawaitable(it):
45 it = await it
46
47 with self.assertRaisesRegex(asyncpg.NoActiveSQLTransactionError,
48 'cursor cannot be created.*transaction'):
49 await it.__anext__()
50
51 async def test_cursor_iterable_03(self):
52 st = await self.con.prepare('SELECT generate_series(0, 20)')

Callers

nothing calls this directly

Calls 5

prepareMethod · 0.80
fetchMethod · 0.45
__aiter__Method · 0.45
cursorMethod · 0.45
__anext__Method · 0.45

Tested by

no test coverage detected