summaryrefslogtreecommitdiff
path: root/tests/forms_tests/field_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-06 14:46:33 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-17 11:49:15 +0100
commit8d98f99a4ab5de6f2c730399f53eba8bf6bea470 (patch)
treec9c643c4c77b0d5fb014270f62ba2ca193befc8a /tests/forms_tests/field_tests
parent0be8095b254fad65b2480d677ebe6098c41bbad6 (diff)
Refs #32873 -- Removed settings.USE_L10N per deprecation timeline.
Diffstat (limited to 'tests/forms_tests/field_tests')
-rw-r--r--tests/forms_tests/field_tests/test_decimalfield.py34
-rw-r--r--tests/forms_tests/field_tests/test_floatfield.py38
2 files changed, 26 insertions, 46 deletions
diff --git a/tests/forms_tests/field_tests/test_decimalfield.py b/tests/forms_tests/field_tests/test_decimalfield.py
index 119a74292c..4e24d553f3 100644
--- a/tests/forms_tests/field_tests/test_decimalfield.py
+++ b/tests/forms_tests/field_tests/test_decimalfield.py
@@ -2,9 +2,8 @@ import decimal
from django.core.exceptions import ValidationError
from django.forms import DecimalField, NumberInput, Widget
-from django.test import SimpleTestCase, ignore_warnings, override_settings
+from django.test import SimpleTestCase, override_settings
from django.utils import formats, translation
-from django.utils.deprecation import RemovedInDjango50Warning
from . import FormFieldAssertionsMixin
@@ -195,31 +194,22 @@ class DecimalFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
localized_d = formats.localize_input(d) # -> '0,1' in French
self.assertFalse(f.has_changed(d, localized_d))
- # 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=",")
+ @override_settings(DECIMAL_SEPARATOR=",")
def test_decimalfield_support_decimal_separator(self):
- f = DecimalField(localize=True)
- self.assertEqual(f.clean("1001,10"), decimal.Decimal("1001.10"))
- self.assertEqual(f.clean("1001.10"), decimal.Decimal("1001.10"))
+ with translation.override(None):
+ f = DecimalField(localize=True)
+ self.assertEqual(f.clean("1001,10"), decimal.Decimal("1001.10"))
+ self.assertEqual(f.clean("1001.10"), decimal.Decimal("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 = DecimalField(localize=True)
- self.assertEqual(f.clean("1.001,10"), decimal.Decimal("1001.10"))
- msg = "'Enter a number.'"
- with self.assertRaisesMessage(ValidationError, msg):
- f.clean("1,001.1")
+ with translation.override(None):
+ f = DecimalField(localize=True)
+ self.assertEqual(f.clean("1.001,10"), decimal.Decimal("1001.10"))
+ msg = "'Enter a number.'"
+ with self.assertRaisesMessage(ValidationError, msg):
+ f.clean("1,001.1")
diff --git a/tests/forms_tests/field_tests/test_floatfield.py b/tests/forms_tests/field_tests/test_floatfield.py
index 94676fb9ee..459ea878de 100644
--- a/tests/forms_tests/field_tests/test_floatfield.py
+++ b/tests/forms_tests/field_tests/test_floatfield.py
@@ -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")