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

Method test_record_subclass_01

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

Source from the content-addressed store, hash-verified

353
354 @tb.with_connection_options(record_class=CustomRecord)
355 async def test_record_subclass_01(self):
356 r = await self.con.fetchrow("SELECT 1 as a, '2' as b")
357 self.assertIsInstance(r, CustomRecord)
358
359 r = await self.con.fetch("SELECT 1 as a, '2' as b")
360 self.assertIsInstance(r[0], CustomRecord)
361
362 async with self.con.transaction():
363 cur = await self.con.cursor("SELECT 1 as a, '2' as b")
364 r = await cur.fetchrow()
365 self.assertIsInstance(r, CustomRecord)
366
367 cur = await self.con.cursor("SELECT 1 as a, '2' as b")
368 r = await cur.fetch(1)
369 self.assertIsInstance(r[0], CustomRecord)
370
371 async with self.con.transaction():
372 cur = self.con.cursor("SELECT 1 as a, '2' as b")
373 async for r in cur:
374 self.assertIsInstance(r, CustomRecord)
375
376 ps = await self.con.prepare("SELECT 1 as a, '2' as b")
377 r = await ps.fetchrow()
378 self.assertIsInstance(r, CustomRecord)
379
380 async def test_record_subclass_02(self):
381 r = await self.con.fetchrow(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected