mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #32873 -- Removed settings.USE_L10N per deprecation timeline.
This commit is contained in:
@@ -2,10 +2,9 @@ from django.core.exceptions import ValidationError
|
||||
from django.forms import FloatField, NumberInput
|
||||
from django.test import SimpleTestCase
|
||||
from django.test.selenium import SeleniumTestCase
|
||||
from django.test.utils import ignore_warnings, override_settings
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils import formats, translation
|
||||
from django.utils.deprecation import RemovedInDjango50Warning
|
||||
|
||||
from . import FormFieldAssertionsMixin
|
||||
|
||||
@@ -111,34 +110,25 @@ class FloatFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
|
||||
localized_n = formats.localize_input(n) # -> '4,35' in French
|
||||
self.assertFalse(f.has_changed(n, localized_n))
|
||||
|
||||
# RemovedInDjango50Warning: When the deprecation ends, remove
|
||||
# @ignore_warnings and USE_L10N=False. The test should remain because
|
||||
# format-related settings will take precedence over locale-dictated
|
||||
# formats.
|
||||
@ignore_warnings(category=RemovedInDjango50Warning)
|
||||
@override_settings(USE_L10N=False, DECIMAL_SEPARATOR=",")
|
||||
def test_decimalfield_support_decimal_separator(self):
|
||||
f = FloatField(localize=True)
|
||||
self.assertEqual(f.clean("1001,10"), 1001.10)
|
||||
self.assertEqual(f.clean("1001.10"), 1001.10)
|
||||
@override_settings(DECIMAL_SEPARATOR=",")
|
||||
def test_floatfield_support_decimal_separator(self):
|
||||
with translation.override(None):
|
||||
f = FloatField(localize=True)
|
||||
self.assertEqual(f.clean("1001,10"), 1001.10)
|
||||
self.assertEqual(f.clean("1001.10"), 1001.10)
|
||||
|
||||
# RemovedInDjango50Warning: When the deprecation ends, remove
|
||||
# @ignore_warnings and USE_L10N=False. The test should remain because
|
||||
# format-related settings will take precedence over locale-dictated
|
||||
# formats.
|
||||
@ignore_warnings(category=RemovedInDjango50Warning)
|
||||
@override_settings(
|
||||
USE_L10N=False,
|
||||
DECIMAL_SEPARATOR=",",
|
||||
USE_THOUSAND_SEPARATOR=True,
|
||||
THOUSAND_SEPARATOR=".",
|
||||
)
|
||||
def test_decimalfield_support_thousands_separator(self):
|
||||
f = FloatField(localize=True)
|
||||
self.assertEqual(f.clean("1.001,10"), 1001.10)
|
||||
msg = "'Enter a number.'"
|
||||
with self.assertRaisesMessage(ValidationError, msg):
|
||||
f.clean("1,001.1")
|
||||
def test_floatfield_support_thousands_separator(self):
|
||||
with translation.override(None):
|
||||
f = FloatField(localize=True)
|
||||
self.assertEqual(f.clean("1.001,10"), 1001.10)
|
||||
msg = "'Enter a number.'"
|
||||
with self.assertRaisesMessage(ValidationError, msg):
|
||||
f.clean("1,001.1")
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF="forms_tests.urls")
|
||||
|
||||
Reference in New Issue
Block a user