Ticket #3971: 3971.diff

File 3971.diff, 2.6 KB (added by Malcolm Tredinnick, 17 years ago)

Updated patch to current svn

  • django/test/simple.py

     
    33from django.test import _doctest as doctest
    44from django.test.utils import setup_test_environment, teardown_test_environment
    55from django.test.utils import create_test_db, destroy_test_db
    6 from django.test.testcases import OutputChecker, DocTestRunner
     6from django.test.testcases import OutputChecker, DocTestRunner, TextTestRunner
    77
    88# The module name for tests outside models.py
    99TEST_MODULE = 'tests'
     
    8383
    8484    old_name = settings.DATABASE_NAME
    8585    create_test_db(verbosity)
    86     result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
     86    result = TextTestRunner(verbosity=verbosity).run(suite)
    8787    destroy_test_db(old_name, verbosity)
    8888   
    8989    teardown_test_environment()
  • django/test/testcases.py

     
    3333        from django.db import transaction
    3434        transaction.rollback_unless_managed()
    3535
    36 class TestCase(unittest.TestCase):   
     36class TestCase(unittest.TestCase):
    3737    def _pre_setup(self):
    3838        """Perform any pre-test setup. This includes:
    3939       
     
    4747            management.load_data(self.fixtures, verbosity=0)
    4848        mail.outbox = []
    4949
    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().
    55         """
    56         self.client = Client()
    57         self._pre_setup()
    58         super(TestCase, self).__call__(result)
    59 
    6050    def assertRedirects(self, response, expected_path, status_code=302, target_status_code=200):
    6151        """Assert that a response redirected to a specific URL, and that the
    6252        redirect URL can be loaded.
     
    146136        elif response.template:
    147137            self.assertNotEqual(template_name, response.template.name,
    148138                "Template '%s' was used unexpectedly in rendering the response" % template_name)
    149        
     139
     140class _TextTestResult(unittest._TextTestResult):
     141    def startTest(self, test):
     142        super(_TextTestResult, self).startTest(test)
     143        if isinstance(test, TestCase):
     144            test._pre_setup()
     145
     146class TextTestRunner(unittest.TextTestRunner):
     147    def _makeResult(self):
     148        return _TextTestResult(self.stream, self.descriptions, self.verbosity)
     149
Back to Top