Django

Code

Changeset 5182

Show
Ignore:
Timestamp:
05/10/07 08:48:18 (1 year ago)
Author:
russellm
Message:

Added the actual assertFormError changes, accidentally omitted from [5181].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/test/testcases.py

    r5179 r5182  
    106106            if form in context: 
    107107                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
    111111                            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)) 
    114117                        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()))) 
    120123        if not found_form: 
    121124            self.fail("The form '%s' was not used to render the response" % form)