Ticket #14319: new_test_signals_patch.diff
File new_test_signals_patch.diff, 3.8 KB (added by , 14 years ago) |
---|
-
django/test/simple.py
7 7 from django.test import _doctest as doctest 8 8 from django.test.utils import setup_test_environment, teardown_test_environment 9 9 from django.test.testcases import OutputChecker, DocTestRunner, TestCase 10 from django.test.signals import test_setup, test_teardown 10 11 11 12 # The module name for tests outside models.py 12 13 TEST_MODULE = 'tests' … … 230 231 self.failfast = failfast 231 232 232 233 def setup_test_environment(self, **kwargs): 233 setup_test_environment()234 test_setup.send(sender=self) 234 235 settings.DEBUG = False 235 236 236 237 def build_suite(self, test_labels, extra_tests=None, **kwargs): … … 284 285 connection.creation.destroy_test_db(old_name, self.verbosity) 285 286 286 287 def teardown_test_environment(self, **kwargs): 287 te ardown_test_environment()288 test_teardown.send(sender=self) 288 289 289 290 def suite_result(self, suite, result, **kwargs): 290 291 return len(result.failures) + len(result.errors) … … 308 309 309 310 Returns the number of tests that failed. 310 311 """ 312 suite = self.build_suite(test_labels, extra_tests) 311 313 self.setup_test_environment() 312 suite = self.build_suite(test_labels, extra_tests)313 314 old_config = self.setup_databases() 314 315 result = self.run_suite(suite) 315 316 self.teardown_databases(old_config) -
django/test/signals.py
1 1 from django.dispatch import Signal 2 2 3 3 template_rendered = Signal(providing_args=["template", "context"]) 4 test_setup = Signal() 5 test_teardown = Signal() 6 No newline at end of file -
django/test/utils.py
52 52 return self.nodelist.render(context) 53 53 54 54 55 def setup_test_environment( ):55 def setup_test_environment(**kwargs): 56 56 """Perform any global pre-test setup. This involves: 57 57 58 58 - Installing the instrumented test renderer … … 71 71 mail.outbox = [] 72 72 73 73 deactivate() 74 signals.test_setup.connect(setup_test_environment) 74 75 75 def teardown_test_environment( ):76 def teardown_test_environment(**kwargs): 76 77 """Perform any global post-test teardown. This involves: 77 78 78 79 - Restoring the original test renderer … … 89 90 del mail.original_email_backend 90 91 91 92 del mail.outbox 93 signals.test_teardown.connect(teardown_test_environment) 92 94 93 95 def get_runner(settings): 94 96 test_path = settings.TEST_RUNNER.split('.') -
docs/ref/signals.txt
455 455 The :class:`~django.template.Context` with which the template was 456 456 rendered. 457 457 458 test_setup 459 ---------- 460 461 .. data:: django.test.signals.test_setup 462 :module: 463 464 .. versionadded:: 1.3 465 466 Sent during global pre-test setup, just after applications have loaded and 467 the test suite has been built. This signal is not emitted during normal 468 operation. 469 470 Arguments sent with this signal: 471 472 sender 473 The :class:`~django.test.simple.DjangoTestSuiteRunner` object. 474 475 test_teardown 476 ------------- 477 478 .. data:: django.test.signals.test_teardown 479 :module: 480 481 .. versionadded:: 1.3 482 483 Sent during global post-test breakdown. This signal is not emitted during 484 normal operation. 485 486 Arguments sent with this signal: 487 488 sender 489 The :class:`~django.test.simple.DjangoTestSuiteRunner` object. 490 458 491 Database Wrappers 459 492 ================= 460 493