Ticket #3971: 3971.diff
File 3971.diff, 2.6 KB (added by , 17 years ago) |
---|
-
django/test/simple.py
3 3 from django.test import _doctest as doctest 4 4 from django.test.utils import setup_test_environment, teardown_test_environment 5 5 from django.test.utils import create_test_db, destroy_test_db 6 from django.test.testcases import OutputChecker, DocTestRunner 6 from django.test.testcases import OutputChecker, DocTestRunner, TextTestRunner 7 7 8 8 # The module name for tests outside models.py 9 9 TEST_MODULE = 'tests' … … 83 83 84 84 old_name = settings.DATABASE_NAME 85 85 create_test_db(verbosity) 86 result = unittest.TextTestRunner(verbosity=verbosity).run(suite)86 result = TextTestRunner(verbosity=verbosity).run(suite) 87 87 destroy_test_db(old_name, verbosity) 88 88 89 89 teardown_test_environment() -
django/test/testcases.py
33 33 from django.db import transaction 34 34 transaction.rollback_unless_managed() 35 35 36 class TestCase(unittest.TestCase): 36 class TestCase(unittest.TestCase): 37 37 def _pre_setup(self): 38 38 """Perform any pre-test setup. This includes: 39 39 … … 47 47 management.load_data(self.fixtures, verbosity=0) 48 48 mail.outbox = [] 49 49 50 def __call__(self, result=None):51 """52 Wrapper around default __call__ method to perform common Django test53 set up. This means that user-defined Test Cases aren't required to54 include a call to super().setUp().55 """56 self.client = Client()57 self._pre_setup()58 super(TestCase, self).__call__(result)59 60 50 def assertRedirects(self, response, expected_path, status_code=302, target_status_code=200): 61 51 """Assert that a response redirected to a specific URL, and that the 62 52 redirect URL can be loaded. … … 146 136 elif response.template: 147 137 self.assertNotEqual(template_name, response.template.name, 148 138 "Template '%s' was used unexpectedly in rendering the response" % template_name) 149 139 140 class _TextTestResult(unittest._TextTestResult): 141 def startTest(self, test): 142 super(_TextTestResult, self).startTest(test) 143 if isinstance(test, TestCase): 144 test._pre_setup() 145 146 class TextTestRunner(unittest.TextTestRunner): 147 def _makeResult(self): 148 return _TextTestResult(self.stream, self.descriptions, self.verbosity) 149