From 58afd30b593fbd1e3d17c1bba83597da07bdb5f5 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 6 Feb 2015 22:29:40 +0100 Subject: [PATCH] Tested DecimalField with scientific notation Refs #15775. --- tests/forms_tests/tests/test_fields.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index ed060bc064..1474698118 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -404,6 +404,13 @@ class FieldsTests(SimpleTestCase): self.assertEqual(f.clean('.01'), Decimal(".01")) self.assertRaisesMessage(ValidationError, "'Ensure that there are no more than 0 digits before the decimal point.'", f.clean, '1.1') + def test_decimalfield_scientific(self): + f = DecimalField(max_digits=2, decimal_places=2) + self.assertEqual(f.clean('1E+2'), Decimal('1E+2')) + self.assertEqual(f.clean('1e+2'), Decimal('1E+2')) + with self.assertRaisesMessage(ValidationError, "Ensure that there are no more"): + f.clean('0.546e+2') + def test_decimalfield_widget_attrs(self): f = DecimalField(max_digits=6, decimal_places=2) self.assertEqual(f.widget_attrs(Widget()), {})