Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 244a5d0006cc831e35e87d2586bb3b6e9ec5926f 1 parent 7090290
Russell Keith-Magee authored May 10, 2007

Showing 1 changed file with 13 additions and 10 deletions. Show diff stats Hide diff stats

  1. 23  django/test/testcases.py
23  django/test/testcases.py
@@ -105,18 +105,21 @@ def assertFormError(self, response, form, field, errors):
105 105
         for i,context in enumerate(contexts):
106 106
             if form in context:
107 107
                 found_form = True
108  
-                try:
109  
-                    for err in errors:
110  
-                        if field:
  108
+                for err in errors:
  109
+                    if field:
  110
+                        if field in context[form].errors:
111 111
                             self.assertTrue(err in context[form].errors[field], 
112  
-                                "The field '%s' on form '%s' in context %d does not contain the error '%s' (actual errors: %s)" % 
113  
-                                    (field, form, i, err, list(context[form].errors[field])))
  112
+                            "The field '%s' on form '%s' in context %d does not contain the error '%s' (actual errors: %s)" % 
  113
+                                (field, form, i, err, list(context[form].errors[field])))
  114
+                        elif field in context[form].fields:
  115
+                            self.fail("The field '%s' on form '%s' in context %d contains no errors" % 
  116
+                                (field, form, i))
114 117
                         else:
115  
-                            self.assertTrue(err in context[form].non_field_errors(), 
116  
-                                "The form '%s' in context %d does not contain the non-field error '%s' (actual errors: %s)" % 
117  
-                                    (form, i, err, list(context[form].non_field_errors())))
118  
-                except KeyError:
119  
-                    self.fail("The form '%s' in context %d does not contain the field '%s'" % (form, i, field))
  118
+                            self.fail("The form '%s' in context %d does not contain the field '%s'" % (form, i, field))
  119
+                    else:
  120
+                        self.assertTrue(err in context[form].non_field_errors(), 
  121
+                            "The form '%s' in context %d does not contain the non-field error '%s' (actual errors: %s)" % 
  122
+                                (form, i, err, list(context[form].non_field_errors())))
120 123
         if not found_form:
121 124
             self.fail("The form '%s' was not used to render the response" % form)
122 125
             

0 notes on commit 244a5d0

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