summaryrefslogtreecommitdiff
path: root/django/test
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-05-10 13:48:18 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-05-10 13:48:18 +0000
commit244a5d0006cc831e35e87d2586bb3b6e9ec5926f (patch)
treeca6841e46ebefa122c9434484335796123cbd82c /django/test
parent70902908c728264f65df40f0aec8474cd7d672c8 (diff)
Added the actual assertFormError changes, accidentally omitted from [5181].
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5182 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/test')
-rw-r--r--django/test/testcases.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index fcf6ccec4d..788e215ca1 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -105,18 +105,21 @@ class TestCase(unittest.TestCase):
for i,context in enumerate(contexts):
if form in context:
found_form = True
- try:
- for err in errors:
- if field:
+ for err in errors:
+ if field:
+ if field in context[form].errors:
self.assertTrue(err in context[form].errors[field],
- "The field '%s' on form '%s' in context %d does not contain the error '%s' (actual errors: %s)" %
- (field, form, i, err, list(context[form].errors[field])))
+ "The field '%s' on form '%s' in context %d does not contain the error '%s' (actual errors: %s)" %
+ (field, form, i, err, list(context[form].errors[field])))
+ elif field in context[form].fields:
+ self.fail("The field '%s' on form '%s' in context %d contains no errors" %
+ (field, form, i))
else:
- self.assertTrue(err in context[form].non_field_errors(),
- "The form '%s' in context %d does not contain the non-field error '%s' (actual errors: %s)" %
- (form, i, err, list(context[form].non_field_errors())))
- except KeyError:
- self.fail("The form '%s' in context %d does not contain the field '%s'" % (form, i, field))
+ self.fail("The form '%s' in context %d does not contain the field '%s'" % (form, i, field))
+ else:
+ self.assertTrue(err in context[form].non_field_errors(),
+ "The form '%s' in context %d does not contain the non-field error '%s' (actual errors: %s)" %
+ (form, i, err, list(context[form].non_field_errors())))
if not found_form:
self.fail("The form '%s' was not used to render the response" % form)