summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms/fields.py
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-08-15 20:09:47 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-08-15 20:09:47 +0000
commit727133109cfb37d73da38d760198eb300125ddb0 (patch)
tree05f747db96d73e2858e7527a304b6568ef920ee7 /tests/regressiontests/forms/fields.py
parent9d1ec0b5ec98188e88c8087ca3fd94302cb9d778 (diff)
Fixed #8290 -- Fixed DecimalField's cleaning of values with a large number of decimal places, based on patch from dgouldin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8391 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/fields.py')
-rw-r--r--tests/regressiontests/forms/fields.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py
index a9aae4f442..ab7968f4a4 100644
--- a/tests/regressiontests/forms/fields.py
+++ b/tests/regressiontests/forms/fields.py
@@ -403,6 +403,33 @@ True
>>> f.clean('00.50') == Decimal("0.50")
True
+
+>>> f = DecimalField(decimal_places=2)
+>>> f.clean('0.00000001')
+Traceback (most recent call last):
+...
+ValidationError: [u'Ensure that there are no more than 2 decimal places.']
+
+
+>>> f = DecimalField(max_digits=3)
+
+# Leading whole zeros "collapse" to one digit.
+>>> f.clean('0000000.10') == Decimal("0.1")
+True
+>>> f.clean('0000000.100')
+Traceback (most recent call last):
+...
+ValidationError: [u'Ensure that there are no more than 3 digits in total.']
+
+# Only leading whole zeros "collapse" to one digit.
+>>> f.clean('000000.02') == Decimal('0.02')
+True
+>>> f.clean('000000.002')
+Traceback (most recent call last):
+...
+ValidationError: [u'Ensure that there are no more than 3 digits in total.']
+
+
# DateField ###################################################################
>>> import datetime