From aa88942c3868b07dd3d969b595e97a1a236b0fe0 Mon Sep 17 00:00:00 2001 From: Huo Linhe Date: Tue, 27 Apr 2021 13:45:08 +0800 Subject: [PATCH] [TD-3639] : compare timestamp with datetime in python (#5940) By this commit, It will close TD-3639. It will not require test case to write *correct* datetime string to pass a test case. One test could use seconds, milliseconds or microseconds to check data. That means the three tests are equivalent: ```python .checkData(0, 0, "2020-01-01 00:00:00") .checkData(0, 0, "2020-01-01 00:00:00.000") .checkData(0, 0, "2020-01-01 00:00:00.000000") ``` --- tests/pytest/util/sql.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index ba9cb4d53d..8f62c5932b 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -136,6 +136,11 @@ class TDSql: def checkData(self, row, col, data): self.checkRowCol(row, col) if self.queryResult[row][col] != data: + if self.cursor.istype(col, "TIMESTAMP") and self.queryResult[row][col] == datetime.datetime.fromisoformat(data): + tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + return + if str(self.queryResult[row][col]) == str(data): tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % (self.sql, row, col, self.queryResult[row][col], data)) -- GitLab