Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

newforms: Changed Form unit tests to use f.clean_data rather than f.c…

…lean(), 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
  • Loading branch information...
commit 3d89f26b0890325870e35142e59f800f5ee68de2 1 parent e1d2332
@adrianholovaty adrianholovaty authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 tests/regressiontests/forms/tests.py
View
14 tests/regressiontests/forms/tests.py
@@ -1148,7 +1148,7 @@
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 @@
* 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 @@
>>> 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 @@
>>> 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 @@
... 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 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 ###################################
Please sign in to comment.
Something went wrong with that request. Please try again.