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

Method test_timetz_encoding

tests/test_codecs.py:1640–1659  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1638 ''')
1639
1640 async def test_timetz_encoding(self):
1641 try:
1642 async with self.con.transaction():
1643 await self.con.execute("SET TIME ZONE 'America/Toronto'")
1644 # Check decoding:
1645 row = await self.con.fetchrow(
1646 'SELECT extract(epoch from now())::float8 AS epoch, '
1647 'now()::date as date, now()::timetz as time')
1648 result = datetime.datetime.combine(row['date'], row['time'])
1649 expected = datetime.datetime.fromtimestamp(row['epoch'],
1650 tz=result.tzinfo)
1651 self.assertEqual(result, expected)
1652
1653 # Check encoding:
1654 res = await self.con.fetchval(
1655 'SELECT now() = ($1::date + $2::timetz)',
1656 row['date'], row['time'])
1657 self.assertTrue(res)
1658 finally:
1659 await self.con.execute('RESET ALL')
1660
1661 async def test_composites_in_arrays(self):
1662 await self.con.execute('''

Callers

nothing calls this directly

Calls 4

transactionMethod · 0.80
executeMethod · 0.45
fetchrowMethod · 0.45
fetchvalMethod · 0.45

Tested by

no test coverage detected