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:
@@ -1,27 +1,14 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
from django.test.utils import override_settings
|
||||
from django.test.utils import override_settings, requires_tz_support
|
||||
from django.utils import timezone
|
||||
from django.utils.unittest import skipUnless
|
||||
|
||||
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.")
|
||||
|
||||
|
||||
def _make_books(n, base_date):
|
||||
for i in range(n):
|
||||
|
||||
Reference in New Issue
Block a user