summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-11-28 23:14:18 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-11-28 23:14:18 +0000
commit3d89f26b0890325870e35142e59f800f5ee68de2 (patch)
treeb3c973e2387306cc078428bf810a0b36d4389f0b /tests/regressiontests
parente1d23323b631436eaae78bb5e4676d83c97d7a6c (diff)
newforms: Changed Form unit tests to use f.clean_data rather than f.clean(), because the latter is a validation hook, not a way to get the clean data
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4129 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/forms/tests.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
index 8f9f0ec24d..3e209da923 100644
--- a/tests/regressiontests/forms/tests.py
+++ b/tests/regressiontests/forms/tests.py
@@ -1148,7 +1148,7 @@ True
u''
>>> p.errors.as_text()
u''
->>> p.clean()
+>>> p.clean_data
{'first_name': u'John', 'last_name': u'Lennon', 'birthday': datetime.date(1940, 10, 9)}
>>> print p['first_name']
<input type="text" name="first_name" value="John" />
@@ -1231,8 +1231,8 @@ u'<ul class="errorlist"><li>first_name<ul class="errorlist"><li>This field is re
* This field is required.
* birthday
* This field is required.
->>> p.clean()
->>> repr(p.clean())
+>>> p.clean_data
+>>> repr(p.clean_data)
'None'
>>> p['first_name'].errors
[u'This field is required.']
@@ -1422,7 +1422,7 @@ including the current field (e.g., the field XXX if you're in clean_XXX()).
>>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'foo'})
>>> f.errors
{}
->>> f.clean()
+>>> f.clean_data
{'username': u'adrian', 'password1': u'foo', 'password2': u'foo'}
Another way of doing multiple-field validation is by implementing the
@@ -1469,7 +1469,7 @@ Form.clean() is required to return a dictionary of all clean data.
>>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'foo'})
>>> f.errors
{}
->>> f.clean()
+>>> f.clean_data
{'username': u'adrian', 'password1': u'foo', 'password2': u'foo'}
It's possible to construct a Form dynamically by adding to the self.fields
@@ -1537,7 +1537,7 @@ A Form's fields are displayed in the same order in which they were defined.
... else:
... form = UserRegistration()
... if form.is_valid():
-... return 'VALID'
+... return 'VALID: %r' % form.clean_data
... t = Template('<form action="" method="post">\n<table>\n{{ form }}\n</table>\n<input type="submit" />\n</form>')
... return t.render(Context({'form': form}))
@@ -1567,7 +1567,7 @@ Case 2: POST with erroneous data (a redisplayed form, with errors).
Case 3: POST with valid data (the success message).
>>> print my_function('POST', {'username': 'adrian', 'password1': 'secret', 'password2': 'secret'})
-VALID
+VALID: {'username': u'adrian', 'password1': u'secret', 'password2': u'secret'}
# Some ideas for using templates with forms ###################################