MCPcopy
hub / github.com/MagicStack/asyncpg / test_cursor_iterable_01

Method test_cursor_iterable_01

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

Source from the content-addressed store, hash-verified

14class TestIterableCursor(tb.ConnectedTestCase):
15
16 async def test_cursor_iterable_01(self):
17 st = await self.con.prepare('SELECT generate_series(0, 20)')
18 expected = await st.fetch()
19
20 for prefetch in range(1, 25):
21 with self.subTest(prefetch=prefetch):
22 async with self.con.transaction():
23 result = []
24 async for rec in st.cursor(prefetch=prefetch):
25 result.append(rec)
26
27 self.assertEqual(
28 result, expected,
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

Callers

nothing calls this directly

Calls 4

prepareMethod · 0.80
transactionMethod · 0.80
fetchMethod · 0.45
cursorMethod · 0.45

Tested by

no test coverage detected