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

Method test_record_subclass_02

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

Source from the content-addressed store, hash-verified

388 self.assertIsInstance(r, CustomRecord)
389
390 async def test_record_subclass_02(self):
391 r = await self.con.fetchrow(
392 "SELECT 1 as a, '2' as b",
393 record_class=CustomRecord,
394 )
395 self.assertIsInstance(r, CustomRecord)
396
397 r = await self.con.fetch(
398 "SELECT 1 as a, '2' as b",
399 record_class=CustomRecord,
400 )
401 self.assertIsInstance(r[0], CustomRecord)
402
403 async with self.con.transaction():
404 cur = await self.con.cursor(
405 "SELECT 1 as a, '2' as b",
406 record_class=CustomRecord,
407 )
408 r = await cur.fetchrow()
409 self.assertIsInstance(r, CustomRecord)
410
411 cur = await self.con.cursor(
412 "SELECT 1 as a, '2' as b",
413 record_class=CustomRecord,
414 )
415 r = await cur.fetch(1)
416 self.assertIsInstance(r[0], CustomRecord)
417
418 async with self.con.transaction():
419 cur = self.con.cursor(
420 "SELECT 1 as a, '2' as b",
421 record_class=CustomRecord,
422 )
423 async for r in cur:
424 self.assertIsInstance(r, CustomRecord)
425
426 ps = await self.con.prepare(
427 "SELECT 1 as a, '2' as b",
428 record_class=CustomRecord,
429 )
430 r = await ps.fetchrow()
431 self.assertIsInstance(r, CustomRecord)
432
433 r = await ps.fetch()
434 self.assertIsInstance(r[0], CustomRecord)
435
436 @tb.with_connection_options(record_class=AnotherCustomRecord)
437 async def test_record_subclass_03(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