summaryrefslogtreecommitdiff
path: root/tests/regressiontests/model_forms_regress/tests.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2010-01-21 02:28:03 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2010-01-21 02:28:03 +0000
commit408d4310291cd1287f3dbc05aaeb5d205eba8751 (patch)
tree88788fcaa4c5fc3f33aacd66ef0c8a0adc7375cc /tests/regressiontests/model_forms_regress/tests.py
parent856a39e841080abc34e8ae3bb2b20f780c33762d (diff)
Fixed #12596. Calling super from a ModelForm's clean method is once again optional. Failing to call super only skips unique validation as documented. Thanks for the initial patch and tests, carljm.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12269 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/model_forms_regress/tests.py')
-rw-r--r--tests/regressiontests/model_forms_regress/tests.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py
index f8b6511140..57d56551e5 100644
--- a/tests/regressiontests/model_forms_regress/tests.py
+++ b/tests/regressiontests/model_forms_regress/tests.py
@@ -50,6 +50,27 @@ class UniqueTogetherTests(TestCase):
form = TripleForm({'left': '1', 'middle': '3', 'right': '1'})
self.failUnless(form.is_valid())
+class TripleFormWithCleanOverride(forms.ModelForm):
+ class Meta:
+ model = Triple
+
+ def clean(self):
+ if not self.cleaned_data['left'] == self.cleaned_data['right']:
+ raise forms.ValidationError('Left and right should be equal')
+ return self.cleaned_data
+
+class OverrideCleanTests(TestCase):
+ def test_override_clean(self):
+ """
+ Regression for #12596: Calling super from ModelForm.clean() should be
+ optional.
+ """
+ form = TripleFormWithCleanOverride({'left': 1, 'middle': 2, 'right': 1})
+ self.failUnless(form.is_valid())
+ # form.instance.left will be None if the instance was not constructed
+ # by form.full_clean().
+ self.assertEquals(form.instance.left, 1)
+
class FPForm(forms.ModelForm):
class Meta:
model = FilePathModel