Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #19203 -- Added isolation to a humanize test

Thanks lrekucki for the report.
  • Loading branch information...
commit aff9b2f5662f8a007bb90a427190c0d573a3ba65 1 parent 5fec97b
Aymeric Augustin authored October 28, 2012
2  django/conf/global_settings.py
@@ -34,7 +34,7 @@
34 34
 # systems may support all possibilities). When USE_TZ is True, this is
35 35
 # interpreted as the default user time zone.
36 36
 TIME_ZONE = 'America/Chicago'
37  
-
  37
+TIME_ZONE = 'Europe/Paris'
38 38
 # If you set this to True, Django will use timezone-aware datetimes.
39 39
 USE_TZ = False
40 40
 
11  django/contrib/humanize/tests.py
... ...
@@ -1,6 +1,12 @@
1 1
 from __future__ import unicode_literals
2 2
 import datetime
3 3
 
  4
+try:
  5
+    import pytz
  6
+except ImportError:
  7
+    pytz = None
  8
+
  9
+from django.conf import settings
4 10
 from django.contrib.humanize.templatetags import humanize
5 11
 from django.template import Template, Context, defaultfilters
6 12
 from django.test import TestCase
@@ -10,6 +16,7 @@
10 16
 from django.utils import translation
11 17
 from django.utils.translation import ugettext as _
12 18
 from django.utils import tzinfo
  19
+from django.utils.unittest import skipIf
13 20
 
14 21
 
15 22
 # Mock out datetime in some tests so they don't fail occasionally when they
@@ -141,6 +148,8 @@ def test_naturalday_tz(self):
141 148
         # As 24h of difference they will never be the same
142 149
         self.assertNotEqual(naturalday_one, naturalday_two)
143 150
 
  151
+    @skipIf(settings.TIME_ZONE != "Ameria/Chicago" and pytz is None,
  152
+            "this test requires pytz when a non-default time zone is set")
144 153
     def test_naturalday_uses_localtime(self):
145 154
         # Regression for #18504
146 155
         # This is 2012-03-08HT19:30:00-06:00 in Ameria/Chicago
@@ -148,7 +157,7 @@ def test_naturalday_uses_localtime(self):
148 157
 
149 158
         orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
150 159
         try:
151  
-            with override_settings(USE_TZ=True):
  160
+            with override_settings(TIME_ZONE="America/Chicago", USE_TZ=True):
152 161
                 self.humanize_tester([dt], ['yesterday'], 'naturalday')
153 162
         finally:
154 163
             humanize.datetime = orig_humanize_datetime

0 notes on commit aff9b2f

Alexey Boriskin

Typo: Ameria instead of America

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