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

Method test_prepare_04

tests/test_prepare.py:65–81  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

63 self.assertEqual(res, val)
64
65 async def test_prepare_04(self):
66 s = await self.con.prepare('SELECT $1::smallint')
67 self.assertEqual(await s.fetchval(10), 10)
68
69 s = await self.con.prepare('SELECT $1::smallint * 2')
70 self.assertEqual(await s.fetchval(10), 20)
71
72 s = await self.con.prepare('SELECT generate_series(5,10)')
73 self.assertEqual(await s.fetchval(), 5)
74 # Since the "execute" message was sent with a limit=1,
75 # we will receive a PortalSuspended message, instead of
76 # CommandComplete. Which means there will be no status
77 # message set.
78 self.assertIsNone(s.get_statusmsg())
79 # Repeat the same test for 'fetchrow()'.
80 self.assertEqual(await s.fetchrow(), (5,))
81 self.assertIsNone(s.get_statusmsg())
82
83 async def test_prepare_05_unknownoid(self):
84 s = await self.con.prepare("SELECT 'test'")

Callers

nothing calls this directly

Calls 4

get_statusmsgMethod · 0.80
prepareMethod · 0.45
fetchvalMethod · 0.45
fetchrowMethod · 0.45

Tested by

no test coverage detected