]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
clarify this test
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 26 Mar 2010 16:18:21 +0000 (12:18 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 26 Mar 2010 16:18:21 +0000 (12:18 -0400)
test/dialect/test_postgresql.py

index dc022bb77be28dc8a0a23893301676cf219cd4de..1d39d565367505e3d1586286a4414f3ad5e7c10c 100644 (file)
@@ -1312,6 +1312,7 @@ class TimezoneTest(TestBase):
             Column("name", String(20)),
         )
         metadata.create_all()
+
     @classmethod
     def teardown_class(cls):
         metadata.drop_all()
@@ -1319,16 +1320,34 @@ class TimezoneTest(TestBase):
     def test_with_timezone(self):
         # get a date with a tzinfo
         somedate = testing.db.connect().scalar(func.current_timestamp().select())
+        assert somedate.tzinfo
+        
         tztable.insert().execute(id=1, name='row1', date=somedate)
-        c = tztable.update(tztable.c.id==1).execute(name='newname')
-        print tztable.select(tztable.c.id==1).execute().first()
+        
+        row = select([tztable.c.date], tztable.c.id==1).execute().first()
+        eq_(row[0], somedate)
+        eq_(somedate.tzinfo.utcoffset(somedate), row[0].tzinfo.utcoffset(row[0]))
+
+        result = tztable.update(tztable.c.id==1).\
+                        returning(tztable.c.date).execute(name='newname')
+        row = result.first()
+        assert row[0] >= somedate
 
     def test_without_timezone(self):
         # get a date without a tzinfo
-        somedate = datetime.datetime(2005, 10,20, 11, 52, 00)
+        somedate = datetime.datetime(2005, 10, 20, 11, 52, 0)
+        assert not somedate.tzinfo
+        
         notztable.insert().execute(id=1, name='row1', date=somedate)
-        c = notztable.update(notztable.c.id==1).execute(name='newname')
-        print notztable.select(tztable.c.id==1).execute().first()
+
+        row = select([notztable.c.date], notztable.c.id==1).execute().first()
+        eq_(row[0], somedate)
+        eq_(row[0].tzinfo, None)
+        
+        result = notztable.update(notztable.c.id==1).\
+                        returning(notztable.c.date).execute(name='newname')
+        row = result.first()
+        assert row[0] >= somedate
 
 class TimePrecisionTest(TestBase, AssertsCompiledSQL):
     __dialect__ = postgresql.dialect()