Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1853 from loic/dst

Fixed failing test around DST change.
  • Loading branch information...
commit 881851f3bbfce226746482109d32e8e2f0f8f45e 2 parents fe995e6 + 757945b
@aaugustin aaugustin authored
Showing with 17 additions and 2 deletions.
  1. +17 −2 tests/admin_widgets/tests.py
View
19 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 @@ def test_date_time_picker_shortcuts(self):
"""
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/'))
Please sign in to comment.
Something went wrong with that request. Please try again.