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

Method test_record_subclass_03

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

Source from the content-addressed store, hash-verified

435
436 @tb.with_connection_options(record_class=AnotherCustomRecord)
437 async def test_record_subclass_03(self):
438 r = await self.con.fetchrow(
439 "SELECT 1 as a, '2' as b",
440 record_class=CustomRecord,
441 )
442 self.assertIsInstance(r, CustomRecord)
443
444 r = await self.con.fetch(
445 "SELECT 1 as a, '2' as b",
446 record_class=CustomRecord,
447 )
448 self.assertIsInstance(r[0], CustomRecord)
449
450 async with self.con.transaction():
451 cur = await self.con.cursor(
452 "SELECT 1 as a, '2' as b",
453 record_class=CustomRecord,
454 )
455 r = await cur.fetchrow()
456 self.assertIsInstance(r, CustomRecord)
457
458 cur = await self.con.cursor(
459 "SELECT 1 as a, '2' as b",
460 record_class=CustomRecord,
461 )
462 r = await cur.fetch(1)
463 self.assertIsInstance(r[0], CustomRecord)
464
465 async with self.con.transaction():
466 cur = self.con.cursor(
467 "SELECT 1 as a, '2' as b",
468 record_class=CustomRecord,
469 )
470 async for r in cur:
471 self.assertIsInstance(r, CustomRecord)
472
473 ps = await self.con.prepare(
474 "SELECT 1 as a, '2' as b",
475 record_class=CustomRecord,
476 )
477 r = await ps.fetchrow()
478 self.assertIsInstance(r, CustomRecord)
479
480 r = await ps.fetch()
481 self.assertIsInstance(r[0], CustomRecord)
482
483 @tb.with_connection_options(record_class=CustomRecord)
484 async def test_record_subclass_04(self):

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