summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-03-27 04:20:21 +0000
committerBrian Rosner <brosner@gmail.com>2008-03-27 04:20:21 +0000
commit10f86fd1eecc405ced4d6e97e10b0f5306b83253 (patch)
treeb4bd6109a6a1757090c62a2febbbbd0aaa04b976 /tests
parent8cbcc7152b307b39bfd45a6b3e695bc5ab87b300 (diff)
newforms-admin: Changed Widget._has_changed to *only* use an empty string when data and/or initial is None. False values were tripping up the conditional.
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7366 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/forms/forms.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/forms.py b/tests/regressiontests/forms/forms.py
index d6f7919ff2..a865e9126c 100644
--- a/tests/regressiontests/forms/forms.py
+++ b/tests/regressiontests/forms/forms.py
@@ -1717,4 +1717,25 @@ Traceback (most recent call last):
...
AttributeError: 'SongForm' object has no attribute 'cleaned_data'
+If a field is not given in the data then None is returned for its data. Lets
+make sure that when checking for empty_permitted that None is treated
+accordingly.
+
+>>> data = {'artist': None, 'song': ''}
+>>> form = SongForm(data, empty_permitted=True)
+>>> form.is_valid()
+True
+
+However, we *really* need to be sure we are checking for None as any data in
+initial that returns False on a boolean call needs to be treated literally.
+
+>>> class PriceForm(Form):
+... amount = FloatField()
+... qty = IntegerField()
+
+>>> data = {'amount': '0.0', 'qty': ''}
+>>> form = PriceForm(data, initial={'amount': 0.0}, empty_permitted=True)
+>>> form.is_valid()
+True
+
"""