Changeset 5211
- Timestamp:
- 05/12/07 11:53:27 (2 years ago)
- Files:
-
- django/trunk/django/test/testcases.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/test/testcases.py
r5182 r5211 1 1 import re, doctest, unittest 2 import sys 2 3 from urlparse import urlparse 3 4 from django.db import transaction … … 46 47 management.load_data(self.fixtures, verbosity=0) 47 48 mail.outbox = [] 48 49 def run(self, result=None):50 """ Wrapper around default run method to perform common Django test set up.51 This means that user-defined Test Cases aren't required to include a call52 to super().setUp().53 49 50 def __call__(self, result=None): 51 """ 52 Wrapper around default __call__ method to perform common Django test 53 set up. This means that user-defined Test Cases aren't required to 54 include a call to super().setUp(). 54 55 """ 55 56 self.client = Client() 56 57 self._pre_setup() 57 super(TestCase, self). run(result)58 super(TestCase, self).__call__(result) 58 59 59 60 def assertRedirects(self, response, expected_path, status_code=302, target_status_code=200): … … 109 110 if field: 110 111 if field in context[form].errors: 111 self. assertTrue(err in context[form].errors[field],112 self.failUnless(err in context[form].errors[field], 112 113 "The field '%s' on form '%s' in context %d does not contain the error '%s' (actual errors: %s)" % 113 114 (field, form, i, err, list(context[form].errors[field]))) … … 118 119 self.fail("The form '%s' in context %d does not contain the field '%s'" % (form, i, field)) 119 120 else: 120 self. assertTrue(err in context[form].non_field_errors(),121 self.failUnless(err in context[form].non_field_errors(), 121 122 "The form '%s' in context %d does not contain the non-field error '%s' (actual errors: %s)" % 122 123 (form, i, err, list(context[form].non_field_errors()))) … … 128 129 if isinstance(response.template, list): 129 130 template_names = [t.name for t in response.template] 130 self. assertTrue(template_name in template_names,131 self.failUnless(template_name in template_names, 131 132 "Template '%s' was not one of the templates used to render the response. Templates used: %s" % 132 133 (template_name, template_names)) … … 141 142 "Assert that the template with the provided name was NOT used in rendering the response" 142 143 if isinstance(response.template, list): 143 self. assertFalse(template_name in [t.name for t in response.template],144 self.failIf(template_name in [t.name for t in response.template], 144 145 "Template '%s' was used unexpectedly in rendering the response" % template_name) 145 146 elif response.template:
