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

Method test_cursor_iterable_06

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

Source from the content-addressed store, hash-verified

81 pass
82
83 async def test_cursor_iterable_06(self):
84 recs = []
85
86 async with self.con.transaction():
87 await self.con.execute('''
88 CREATE TABLE cursor_iterable_06 (id int);
89 INSERT INTO cursor_iterable_06 VALUES (0), (1);
90 ''')
91 try:
92 cur = self.con.cursor('SELECT * FROM cursor_iterable_06')
93 async for rec in cur:
94 recs.append(rec)
95 finally:
96 # Check that after iteration has exhausted the cursor,
97 # its associated portal is closed properly, unlocking
98 # the table.
99 await self.con.execute('DROP TABLE cursor_iterable_06')
100
101 self.assertEqual(recs, [(i,) for i in range(2)])
102
103
104class TestCursor(tb.ConnectedTestCase):

Callers

nothing calls this directly

Calls 3

transactionMethod · 0.80
executeMethod · 0.45
cursorMethod · 0.45

Tested by

no test coverage detected