Skip to content

Commit

Permalink
Fixed #21756 -- Skipped two timezone-related tests on Windows.
Browse files Browse the repository at this point in the history
Windows cannot use a time zone other than the default time zone.

Thanks manfre for the report.
  • Loading branch information
aaugustin committed Jan 12, 2014
1 parent 3d4ed28 commit 9cc3371
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/utils_tests/test_dateformat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import unicode_literals

from datetime import datetime, date
import time

from django.test import TestCase, override_settings
from django.test.utils import TZ_SUPPORT, requires_tz_support
from django.utils.dateformat import format
from django.utils import dateformat
from django.utils.timezone import utc, get_fixed_timezone, get_default_timezone, make_aware
Expand All @@ -13,9 +13,6 @@
@override_settings(TIME_ZONE='Europe/Copenhagen')
class DateFormatTests(TestCase):

# Run tests that require a time zone only when the OS supports it.
tz_tests = hasattr(time, 'tzset')

def setUp(self):
self._orig_lang = translation.get_language()
translation.activate('en-us')
Expand All @@ -31,12 +28,14 @@ def test_naive_datetime(self):
dt = datetime(2009, 5, 16, 5, 30, 30)
self.assertEqual(datetime.fromtimestamp(int(format(dt, 'U'))), dt)

@requires_tz_support
def test_datetime_with_local_tzinfo(self):
ltz = get_default_timezone()
dt = make_aware(datetime(2009, 5, 16, 5, 30, 30), ltz)
self.assertEqual(datetime.fromtimestamp(int(format(dt, 'U')), ltz), dt)
self.assertEqual(datetime.fromtimestamp(int(format(dt, 'U'))), dt.replace(tzinfo=None))

@requires_tz_support
def test_datetime_with_tzinfo(self):
tz = get_fixed_timezone(-510)
ltz = get_default_timezone()
Expand Down Expand Up @@ -117,7 +116,7 @@ def test_timezones(self):
tz = get_fixed_timezone(-210)
aware_dt = datetime(2009, 5, 16, 5, 30, 30, tzinfo=tz)

if self.tz_tests:
if TZ_SUPPORT:
self.assertEqual(dateformat.format(my_birthday, 'O'), '+0100')
self.assertEqual(dateformat.format(my_birthday, 'r'), 'Sun, 8 Jul 1979 22:00:00 +0100')
self.assertEqual(dateformat.format(my_birthday, 'T'), 'CET')
Expand Down

0 comments on commit 9cc3371

Please sign in to comment.