summaryrefslogtreecommitdiff
path: root/tests/timezones
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2021-09-09 07:42:05 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-14 12:05:43 +0200
commit676bd084f2509f4201561d5c77ed4ecbd157bfa0 (patch)
treebc8dfe6748a6bfc5fe8c728a5f825dfff575cb56 /tests/timezones
parent04e023e38331d6717af1cbd8da4926af612f7831 (diff)
downloaddjango-676bd084f2509f4201561d5c77ed4ecbd157bfa0.tar.gz
Fixed #32873 -- Deprecated settings.USE_L10N.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'tests/timezones')
-rw-r--r--tests/timezones/tests.py30
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):