Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 04018a1

Browse files
committed
Fix for presto
1 parent 44cf693 commit 04018a1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_database.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ def test_correct_timezone(self):
9393
tz = pytz.timezone('Europe/Berlin')
9494

9595
now = datetime.now(tz)
96-
db.query(table(name).insert_row("1", now, now))
96+
if isinstance(db, dbs.Presto):
97+
ms = now.microsecond // 1000 * 1000 # Presto max precision is 3
98+
now = now.replace(microsecond = ms)
99+
100+
db.query(table(name).insert_row(1, now, now))
97101
db.query(db.dialect.set_timezone_to_utc())
98102

99103
t = db.table(name).query_schema()
@@ -107,9 +111,11 @@ def test_correct_timezone(self):
107111
updated_at = results[0][1]
108112

109113
utc = now.astimezone(pytz.UTC)
114+
expected = utc.__format__("%Y-%m-%d %H:%M:%S.%f")
115+
110116

111-
self.assertEqual(created_at, utc.__format__("%Y-%m-%d %H:%M:%S.%f"))
112-
self.assertEqual(updated_at, utc.__format__("%Y-%m-%d %H:%M:%S.%f"))
117+
self.assertEqual(created_at, expected)
118+
self.assertEqual(updated_at, expected)
113119

114120
db.query(tbl.drop())
115121

0 commit comments

Comments
 (0)