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

Method test_record_subclass_01

tests/test_record.py:365–388  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

363
364 @tb.with_connection_options(record_class=CustomRecord)
365 async def test_record_subclass_01(self):
366 r = await self.con.fetchrow("SELECT 1 as a, '2' as b")
367 self.assertIsInstance(r, CustomRecord)
368
369 r = await self.con.fetch("SELECT 1 as a, '2' as b")
370 self.assertIsInstance(r[0], CustomRecord)
371
372 async with self.con.transaction():
373 cur = await self.con.cursor("SELECT 1 as a, '2' as b")
374 r = await cur.fetchrow()
375 self.assertIsInstance(r, CustomRecord)
376
377 cur = await self.con.cursor("SELECT 1 as a, '2' as b")
378 r = await cur.fetch(1)
379 self.assertIsInstance(r[0], CustomRecord)
380
381 async with self.con.transaction():
382 cur = self.con.cursor("SELECT 1 as a, '2' as b")
383 async for r in cur:
384 self.assertIsInstance(r, CustomRecord)
385
386 ps = await self.con.prepare("SELECT 1 as a, '2' as b")
387 r = await ps.fetchrow()
388 self.assertIsInstance(r, CustomRecord)
389
390 async def test_record_subclass_02(self):
391 r = await self.con.fetchrow(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected