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

Method test_timetz_encoding

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

Source from the content-addressed store, hash-verified

1592 ''')
1593
1594 async def test_timetz_encoding(self):
1595 try:
1596 async with self.con.transaction():
1597 await self.con.execute("SET TIME ZONE 'America/Toronto'")
1598 # Check decoding:
1599 row = await self.con.fetchrow(
1600 'SELECT extract(epoch from now())::float8 AS epoch, '
1601 'now()::date as date, now()::timetz as time')
1602 result = datetime.datetime.combine(row['date'], row['time'])
1603 expected = datetime.datetime.fromtimestamp(row['epoch'],
1604 tz=result.tzinfo)
1605 self.assertEqual(result, expected)
1606
1607 # Check encoding:
1608 res = await self.con.fetchval(
1609 'SELECT now() = ($1::date + $2::timetz)',
1610 row['date'], row['time'])
1611 self.assertTrue(res)
1612 finally:
1613 await self.con.execute('RESET ALL')
1614
1615 async def test_composites_in_arrays(self):
1616 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