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

Method test_record_subclass_02

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

Source from the content-addressed store, hash-verified

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