Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a new form test that I forgot to commit in [5348]. Refs #3718.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5354 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 193a83ca509acfb3db4694809461a1476f6530bb 1 parent aae36cf
Malcolm Tredinnick authored May 26, 2007

Showing 1 changed file with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. 19  tests/regressiontests/forms/tests.py
19  tests/regressiontests/forms/tests.py
@@ -3655,6 +3655,25 @@
3655 3655
 u' class="news" title="Read this"'
3656 3656
 >>> flatatt({})
3657 3657
 u''
  3658
+
  3659
+####################################
  3660
+# Test accessing errors in clean() #
  3661
+####################################
  3662
+
  3663
+>>> class UserForm(Form):
  3664
+...     username = CharField(max_length=10)
  3665
+...     password = CharField(widget=PasswordInput)
  3666
+...     def clean(self):
  3667
+...         data = self.cleaned_data
  3668
+...         if not self.errors:
  3669
+...             data['username'] = data['username'].lower()
  3670
+...         return data
  3671
+
  3672
+>>> f = UserForm({'username': 'SirRobin', 'password': 'blue'})
  3673
+>>> f.is_valid()
  3674
+True
  3675
+>>> f.cleaned_data['username']
  3676
+u'sirrobin'
3658 3677
 """
3659 3678
 
3660 3679
 __test__ = {

0 notes on commit 193a83c

Please sign in to comment.
Something went wrong with that request. Please try again.