diff options
Diffstat (limited to 'tests/timezones')
-rw-r--r-- | tests/timezones/tests.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 7b54ec3bfc..98c5cdac33 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -24,12 +24,13 @@ from django.template import ( Context, RequestContext, Template, TemplateSyntaxError, context_processors, ) from django.test import ( - SimpleTestCase, TestCase, TransactionTestCase, override_settings, - skipIfDBFeature, skipUnlessDBFeature, + SimpleTestCase, TestCase, TransactionTestCase, ignore_warnings, + override_settings, skipIfDBFeature, skipUnlessDBFeature, ) from django.test.utils import requires_tz_support from django.urls import reverse from django.utils import timezone +from django.utils.deprecation import RemovedInDjango50Warning from django.utils.timezone import timedelta from .forms import ( @@ -812,8 +813,15 @@ class SerializationTests(SimpleTestCase): self.assertEqual(obj.dt, dt) +# RemovedInDjango50Warning: When the deprecation ends, remove setUpClass() and +# USE_L10N=False. The tests should remain because format-related settings will +# take precedence over locale-dictated formats. @override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True) class TemplateTests(SimpleTestCase): + @classmethod + def setUpClass(cls): + with ignore_warnings(category=RemovedInDjango50Warning): + super().setUpClass() @requires_tz_support def test_localtime_templatetag_and_filters(self): @@ -1072,8 +1080,15 @@ class TemplateTests(SimpleTestCase): self.assertEqual(tpl.render(Context({})), "+0700") +# RemovedInDjango50Warning: When the deprecation ends, remove setUpClass() and +# USE_L10N=False. The tests should remain because format-related settings will +# take precedence over locale-dictated formats. @override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=False) class LegacyFormsTests(TestCase): + @classmethod + def setUpClass(cls): + with ignore_warnings(category=RemovedInDjango50Warning): + super().setUpClass() def test_form(self): form = EventForm({'dt': '2011-09-01 13:20:30'}) @@ -1109,8 +1124,15 @@ class LegacyFormsTests(TestCase): self.assertEqual(e.dt, datetime.datetime(2011, 9, 1, 13, 20, 30)) +# RemovedInDjango50Warning: When the deprecation ends, remove setUpClass() and +# USE_L10N=False. The tests should remain because format-related settings will +# take precedence over locale-dictated formats. @override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True) class NewFormsTests(TestCase): + @classmethod + def setUpClass(cls): + with ignore_warnings(category=RemovedInDjango50Warning): + super().setUpClass() @requires_tz_support def test_form(self): @@ -1183,6 +1205,10 @@ class NewFormsTests(TestCase): ROOT_URLCONF='timezones.urls', ) class AdminTests(TestCase): + @classmethod + def setUpClass(cls): + with ignore_warnings(category=RemovedInDjango50Warning): + super().setUpClass() @classmethod def setUpTestData(cls): |