From 193a83ca509acfb3db4694809461a1476f6530bb Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 26 May 2007 09:47:47 +0000 Subject: [PATCH] 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 --- tests/regressiontests/forms/tests.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index ba5beed5e5..4844267b43 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -3655,6 +3655,25 @@ u' id="header"' u' class="news" title="Read this"' >>> flatatt({}) u'' + +#################################### +# Test accessing errors in clean() # +#################################### + +>>> class UserForm(Form): +... username = CharField(max_length=10) +... password = CharField(widget=PasswordInput) +... def clean(self): +... data = self.cleaned_data +... if not self.errors: +... data['username'] = data['username'].lower() +... return data + +>>> f = UserForm({'username': 'SirRobin', 'password': 'blue'}) +>>> f.is_valid() +True +>>> f.cleaned_data['username'] +u'sirrobin' """ __test__ = {