Loading django/test/utils.py +14 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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): Loading Loading @@ -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.") tests/generic_views/test_dates.py +1 −14 Original line number Diff line number Diff line from __future__ import unicode_literals import time import datetime from unittest import skipUnless 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 .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): Loading tests/timezones/tests.py +2 −14 Original line number Diff line number Diff line Loading @@ -4,8 +4,7 @@ import datetime import os import re import sys import time from unittest import skipIf, skipUnless from unittest import skipIf import warnings from xml.dom.minidom import parseString Loading @@ -22,7 +21,7 @@ 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 Loading @@ -42,17 +41,6 @@ UTC = timezone.utc EAT = timezone.get_fixed_timezone(180) # Africa/Nairobi ICT = timezone.get_fixed_timezone(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): Loading Loading
django/test/utils.py +14 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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): Loading Loading @@ -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.")
tests/generic_views/test_dates.py +1 −14 Original line number Diff line number Diff line from __future__ import unicode_literals import time import datetime from unittest import skipUnless 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 .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): Loading
tests/timezones/tests.py +2 −14 Original line number Diff line number Diff line Loading @@ -4,8 +4,7 @@ import datetime import os import re import sys import time from unittest import skipIf, skipUnless from unittest import skipIf import warnings from xml.dom.minidom import parseString Loading @@ -22,7 +21,7 @@ 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 Loading @@ -42,17 +41,6 @@ UTC = timezone.utc EAT = timezone.get_fixed_timezone(180) # Africa/Nairobi ICT = timezone.get_fixed_timezone(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): Loading