Commit f9c73b2a authored by Sebastien Robin's avatar Sebastien Robin

fonctional tests: use UTC timezone to avoid failures in tests sensible to DST

Some tests are sensible to Daylight saving time when they do some checking
with non fixed dates
parent a49d3b9e
...@@ -367,6 +367,7 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase): ...@@ -367,6 +367,7 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
super(ERP5TypeFunctionalTestCase, self).afterSetUp() super(ERP5TypeFunctionalTestCase, self).afterSetUp()
# create browser_id_manager # create browser_id_manager
self.setTimeZoneToUTC()
if not "browser_id_manager" in self.portal.objectIds(): if not "browser_id_manager" in self.portal.objectIds():
self.portal.manage_addProduct['Sessions'].constructBrowserIdManager() self.portal.manage_addProduct['Sessions'].constructBrowserIdManager()
self.commit() self.commit()
......
...@@ -288,6 +288,17 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -288,6 +288,17 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
assert date_time is None or isinstance(date_time, DateTime) assert date_time is None or isinstance(date_time, DateTime)
_pinned_date_time = date_time _pinned_date_time = date_time
def setTimeZoneToUTC(self):
# Make sure tests runs with UTC timezone. Some tests are checking values
# based on now, and this could give unexpected results:
# DateTime("2016/10/31") - DateTime("2016/10/30") = 1.0416666666666667 if
# you are running on a timezone like Europe/Paris, while it return 1.0 for
# UTC
os.environ['TZ'] = "UTC"
time.tzset()
DateTime._isDST = False
DateTime._localzone = DateTime._localzone0 = DateTime._localzone1 = "UTC"
def unpinDateTime(self): def unpinDateTime(self):
self.pinDateTime(None) self.pinDateTime(None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment