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

Method test_record_subclass_03

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

Source from the content-addressed store, hash-verified

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

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