summaryrefslogtreecommitdiff
path: root/tests/admin_widgets
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@sixmedia.com>2013-11-02 18:57:35 -0500
committerLoic Bistuer <loic.bistuer@sixmedia.com>2013-11-02 18:57:35 -0500
commit757945b47de45b6eaa0b0e14f87936261a60d227 (patch)
tree23de641e3f3202cb686ca0bf5e720a7d0316ad74 /tests/admin_widgets
parent2bba0d275bdf392deb144a6e83392a80d57c8c03 (diff)
Fixed failing test around DST change.
The timezone arithmetic done in JS can be off by one hour around DST change. We work around this issue by adding one extra hour to the test error margin when we detect a DST change is near. Refs #20663.
Diffstat (limited to 'tests/admin_widgets')
-rw-r--r--tests/admin_widgets/tests.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 0aa8e98933..e6f33b04e0 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -2,7 +2,12 @@
from __future__ import unicode_literals
from datetime import datetime, timedelta
-from unittest import TestCase
+from unittest import TestCase, skipIf
+
+try:
+ import pytz
+except ImportError:
+ pytz = None
from django import forms
from django.conf import settings
@@ -635,6 +640,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
+@skipIf(pytz is None, "this test requires pytz")
@override_settings(TIME_ZONE='Asia/Singapore')
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
class DateTimePickerShortcutsSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
@@ -654,9 +660,18 @@ class DateTimePickerShortcutsSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase
"""
self.admin_login(username='super', password='secret', login_url='/')
- now = datetime.now()
error_margin = timedelta(seconds=10)
+ # If we are neighbouring a DST, we add an hour of error margin.
+ tz = pytz.timezone('America/Chicago')
+ utc_now = datetime.now(pytz.utc)
+ tz_yesterday = (utc_now - timedelta(days=1)).astimezone(tz).tzname()
+ tz_tomorrow = (utc_now + timedelta(days=1)).astimezone(tz).tzname()
+ if tz_yesterday != tz_tomorrow:
+ error_margin += timedelta(hours=1)
+
+ now = datetime.now()
+
self.selenium.get('%s%s' % (self.live_server_url,
'/admin_widgets/member/add/'))