Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #1853 from loic/dst

Fixed failing test around DST change.
  • Loading branch information...
commit 881851f3bbfce226746482109d32e8e2f0f8f45e 2 parents fe995e6 + 757945b
Aymeric Augustin authored November 03, 2013

Showing 1 changed file with 17 additions and 2 deletions. Show diff stats Hide diff stats

  1. 19  tests/admin_widgets/tests.py
19  tests/admin_widgets/tests.py
@@ -2,7 +2,12 @@
2 2
 from __future__ import unicode_literals
3 3
 
4 4
 from datetime import datetime, timedelta
5  
-from unittest import TestCase
  5
+from unittest import TestCase, skipIf
  6
+
  7
+try:
  8
+    import pytz
  9
+except ImportError:
  10
+    pytz = None
6 11
 
7 12
 from django import forms
8 13
 from django.conf import settings
@@ -635,6 +640,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
635 640
     webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
636 641
 
637 642
 
  643
+@skipIf(pytz is None, "this test requires pytz")
638 644
 @override_settings(TIME_ZONE='Asia/Singapore')
639 645
 @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
640 646
 class DateTimePickerShortcutsSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
@@ -654,9 +660,18 @@ def test_date_time_picker_shortcuts(self):
654 660
         """
655 661
         self.admin_login(username='super', password='secret', login_url='/')
656 662
 
657  
-        now = datetime.now()
658 663
         error_margin = timedelta(seconds=10)
659 664
 
  665
+        # If we are neighbouring a DST, we add an hour of error margin.
  666
+        tz = pytz.timezone('America/Chicago')
  667
+        utc_now = datetime.now(pytz.utc)
  668
+        tz_yesterday = (utc_now - timedelta(days=1)).astimezone(tz).tzname()
  669
+        tz_tomorrow = (utc_now + timedelta(days=1)).astimezone(tz).tzname()
  670
+        if tz_yesterday != tz_tomorrow:
  671
+            error_margin += timedelta(hours=1)
  672
+
  673
+        now = datetime.now()
  674
+
660 675
         self.selenium.get('%s%s' % (self.live_server_url,
661 676
             '/admin_widgets/member/add/'))
662 677
 

0 notes on commit 881851f

Please sign in to comment.
Something went wrong with that request. Please try again.