mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Factorized requires_tz_support decorator in test utils
Thanks Aymeric Augustin for the suggestion. Refs #21165.
This commit is contained in:
@@ -2,6 +2,8 @@ from contextlib import contextmanager
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from unittest import skipUnless
|
||||
import warnings
|
||||
from functools import wraps
|
||||
from xml.dom.minidom import parseString, Node
|
||||
@@ -21,10 +23,11 @@ from django.utils.translation import deactivate
|
||||
|
||||
__all__ = (
|
||||
'Approximate', 'ContextList', 'get_runner', 'override_settings',
|
||||
'setup_test_environment', 'teardown_test_environment',
|
||||
'requires_tz_support', 'setup_test_environment', 'teardown_test_environment',
|
||||
)
|
||||
|
||||
RESTORE_LOADERS_ATTR = '_original_template_source_loaders'
|
||||
TZ_SUPPORT = hasattr(time, 'tzset')
|
||||
|
||||
|
||||
class Approximate(object):
|
||||
@@ -417,3 +420,13 @@ def patch_logger(logger_name, log_level):
|
||||
yield calls
|
||||
finally:
|
||||
setattr(logger, log_level, orig)
|
||||
|
||||
|
||||
# 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.")
|
||||
|
||||
Reference in New Issue
Block a user