1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.6.x] Factorized requires_tz_support decorator in test utils

Thanks Aymeric Augustin for the suggestion. Refs #21165.
Backport of c1c44b2506 from master.
This commit is contained in:
Claude Paroz
2013-10-01 09:27:31 +02:00
parent 47a65ad40e
commit 5b97b99a01
3 changed files with 17 additions and 29 deletions

View File

@@ -4,7 +4,6 @@ import datetime
import os
import re
import sys
import time
import warnings
from xml.dom.minidom import parseString
@@ -21,11 +20,11 @@ from django.db.models import Min, Max
from django.http import HttpRequest
from django.template import Context, RequestContext, Template, TemplateSyntaxError
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import override_settings
from django.test.utils import override_settings, requires_tz_support
from django.utils import six
from django.utils import timezone
from django.utils.tzinfo import FixedOffset
from django.utils.unittest import skipIf, skipUnless
from django.utils.unittest import skipIf
from .forms import EventForm, EventSplitForm, EventLocalizedForm, EventModelForm, EventLocalizedModelForm
from .models import Event, MaybeEvent, Session, SessionEvent, Timestamp, AllDayEvent
@@ -43,17 +42,6 @@ UTC = timezone.utc
EAT = FixedOffset(180) # Africa/Nairobi
ICT = FixedOffset(420) # Asia/Bangkok
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.")
@override_settings(TIME_ZONE='Africa/Nairobi', USE_TZ=False)
class LegacyDatabaseTests(TestCase):