mirror of https://github.com/django/django.git
Decorated some tests that require tz support.
This allows the test suite to run without errors on Windows.
This commit is contained in:
parent
900816464d
commit
be7f1099c6
|
@ -467,6 +467,7 @@ class NewDatabaseTests(TestCase):
|
||||||
[event],
|
[event],
|
||||||
transform=lambda d: d)
|
transform=lambda d: d)
|
||||||
|
|
||||||
|
@requires_tz_support
|
||||||
def test_filter_date_field_with_aware_datetime(self):
|
def test_filter_date_field_with_aware_datetime(self):
|
||||||
# Regression test for #17742
|
# Regression test for #17742
|
||||||
day = datetime.date(2011, 9, 1)
|
day = datetime.date(2011, 9, 1)
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.utils.unittest import skipUnless
|
||||||
|
|
||||||
from .models import Book, BookSigning
|
from .models import Book, BookSigning
|
||||||
|
|
||||||
|
TZ_SUPPORT = hasattr(time, 'tzset')
|
||||||
|
|
||||||
|
# On OSes that don't provide tzset (Windows), we can't set the timezone
|
||||||
|
# in which the program runs. As a consequence, we must skip tests that
|
||||||
|
# don't enforce a specific timezone (with timezone.override or equivalent),
|
||||||
|
# or attempt to interpret naive datetimes in the default timezone.
|
||||||
|
|
||||||
|
requires_tz_support = skipUnless(TZ_SUPPORT,
|
||||||
|
"This test relies on the ability to run a program in an arbitrary "
|
||||||
|
"time zone, but your operating system isn't able to do that.")
|
||||||
|
|
||||||
|
|
||||||
class ArchiveIndexViewTests(TestCase):
|
class ArchiveIndexViewTests(TestCase):
|
||||||
fixtures = ['generic-views-test-data.json']
|
fixtures = ['generic-views-test-data.json']
|
||||||
|
@ -100,6 +113,7 @@ class ArchiveIndexViewTests(TestCase):
|
||||||
res = self.client.get('/dates/booksignings/')
|
res = self.client.get('/dates/booksignings/')
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
@requires_tz_support
|
||||||
@override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi')
|
@override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi')
|
||||||
def test_aware_datetime_archive_view(self):
|
def test_aware_datetime_archive_view(self):
|
||||||
BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc))
|
BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc))
|
||||||
|
@ -502,6 +516,7 @@ class DayArchiveViewTests(TestCase):
|
||||||
res = self.client.get('/dates/booksignings/2008/apr/2/')
|
res = self.client.get('/dates/booksignings/2008/apr/2/')
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
@requires_tz_support
|
||||||
@override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi')
|
@override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi')
|
||||||
def test_aware_datetime_day_view(self):
|
def test_aware_datetime_day_view(self):
|
||||||
bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc))
|
bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc))
|
||||||
|
@ -578,6 +593,7 @@ class DateDetailViewTests(TestCase):
|
||||||
res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk)
|
res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk)
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
@requires_tz_support
|
||||||
@override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi')
|
@override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi')
|
||||||
def test_aware_datetime_date_detail(self):
|
def test_aware_datetime_date_detail(self):
|
||||||
bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc))
|
bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc))
|
||||||
|
|
Loading…
Reference in New Issue