summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2013-08-08 14:05:55 +0100
committerMarc Tamlyn <marc.tamlyn@gmail.com>2013-08-08 14:05:55 +0100
commitfb1dd6b13a0e6b1ef64eac88467321d097942cd2 (patch)
tree7dfdd7b3f7a5cb2f63c5046cedfb90fa4884163c /tests
parent7a2296eb5bb05a4109392f8333e934d576d79d35 (diff)
Form.clean() does not need to return cleaned_data.
If it does, that will be used as the cleaned_data. The default implementation has been changed to match this change.
Diffstat (limited to 'tests')
-rw-r--r--tests/forms_tests/tests/test_extra.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_extra.py b/tests/forms_tests/tests/test_extra.py
index afdfaf5281..ba835495c6 100644
--- a/tests/forms_tests/tests/test_extra.py
+++ b/tests/forms_tests/tests/test_extra.py
@@ -620,6 +620,24 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self.assertTrue(f.is_valid())
self.assertEqual(f.cleaned_data['username'], 'sirrobin')
+ def test_changing_cleaned_data_in_clean(self):
+ class UserForm(Form):
+ username = CharField(max_length=10)
+ password = CharField(widget=PasswordInput)
+
+ def clean(self):
+ data = self.cleaned_data
+
+ # Return a different dict. We have not changed self.cleaned_data.
+ return {
+ 'username': data['username'].lower(),
+ 'password': 'this_is_not_a_secret',
+ }
+
+ f = UserForm({'username': 'SirRobin', 'password': 'blue'})
+ self.assertTrue(f.is_valid())
+ self.assertEqual(f.cleaned_data['username'], 'sirrobin')
+
def test_overriding_errorlist(self):
@python_2_unicode_compatible
class DivErrorList(ErrorList):