1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #32873 -- Deprecated settings.USE_L10N.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
Claude Paroz
2021-09-09 07:42:05 +02:00
committed by Mariusz Felisiak
parent 04e023e383
commit 676bd084f2
48 changed files with 335 additions and 148 deletions

View File

@@ -1,8 +1,9 @@
from datetime import datetime
from django.forms import DateTimeInput
from django.test import override_settings
from django.test import ignore_warnings
from django.utils import translation
from django.utils.deprecation import RemovedInDjango50Warning
from .base import WidgetTest
@@ -39,7 +40,6 @@ class DateTimeInputTest(WidgetTest):
d = datetime(2007, 9, 17, 12, 51, 34, 482548)
self.check_html(widget, 'date', d, html='<input type="datetime" name="date" value="17/09/2007 12:51">')
@override_settings(USE_L10N=True)
@translation.override('de-at')
def test_l10n(self):
d = datetime(2007, 9, 17, 12, 51, 34, 482548)
@@ -47,15 +47,22 @@ class DateTimeInputTest(WidgetTest):
'<input type="text" name="date" value="17.09.2007 12:51:34">'
))
@override_settings(USE_L10N=True)
@translation.override('de-at')
def test_locale_aware(self):
d = datetime(2007, 9, 17, 12, 51, 34, 482548)
with self.settings(USE_L10N=False):
self.check_html(
self.widget, 'date', d,
html='<input type="text" name="date" value="2007-09-17 12:51:34">',
)
# RemovedInDjango50Warning: When the deprecation ends, remove
# @ignore_warnings and USE_L10N=False. The assertion should remain
# because format-related settings will take precedence over
# locale-dictated formats.
with ignore_warnings(category=RemovedInDjango50Warning):
with self.settings(USE_L10N=False):
with self.settings(DATETIME_INPUT_FORMATS=[
'%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M',
]):
self.check_html(
self.widget, 'date', d,
html='<input type="text" name="date" value="2007-09-17 12:51:34">',
)
with translation.override('es'):
self.check_html(
self.widget, 'date', d,