From d95cba5badefe3dc554fbbdad729cc315aa33092 Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Tue, 18 Jan 2011 05:48:44 +0100 Subject: [PATCH] TimestampTestCase: replace sql string by func.now. Signed-off-by: Torsten Werner --- tests/dbtest_timestamps.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/dbtest_timestamps.py b/tests/dbtest_timestamps.py index 98642c41..1a53ae86 100755 --- a/tests/dbtest_timestamps.py +++ b/tests/dbtest_timestamps.py @@ -4,6 +4,7 @@ from db_test import DBDakTestCase from daklib.dbconn import DBConn, Uid +from sqlalchemy import func import time import unittest @@ -16,10 +17,13 @@ class TimestampTestCase(DBDakTestCase): """ def now(self): + "returns the current time at the db server" + + # we fetch a fresh session each time to avoid caching local_session = DBConn().session() - query = local_session.query('now').from_statement('select now() as now') + current_time = local_session.query(func.now()).scalar() local_session.close() - return query.first().now + return current_time def sleep(self): time.sleep(0.001) -- 2.39.5