Ticket #14319: new_test_signals_patch_2.diff
File new_test_signals_patch_2.diff, 3.7 KB (added by , 14 years ago) |
---|
-
docs/ref/signals.txt
481 481 The :class:`~django.template.Context` with which the template was 482 482 rendered. 483 483 484 test_setup 485 ---------- 486 487 .. data:: django.test.signals.test_setup 488 :module: 489 490 .. versionadded:: 1.3 491 492 Sent during global pre-test setup, just after applications have loaded and 493 the test suite has been built. This signal is not emitted during normal 494 operation. 495 496 Arguments sent with this signal: 497 498 sender 499 The :class:`~django.test.simple.DjangoTestSuiteRunner` object. 500 501 test_teardown 502 ------------- 503 504 .. data:: django.test.signals.test_teardown 505 :module: 506 507 .. versionadded:: 1.3 508 509 Sent during global post-test breakdown. This signal is not emitted during 510 normal operation. 511 512 Arguments sent with this signal: 513 514 sender 515 The :class:`~django.test.simple.DjangoTestSuiteRunner` object. 516 484 517 Database Wrappers 485 518 ================= 486 519 -
django/test/simple.py
5 5 from django.test import _doctest as doctest 6 6 from django.test.utils import setup_test_environment, teardown_test_environment 7 7 from django.test.testcases import OutputChecker, DocTestRunner, TestCase 8 from django.test.signals import test_setup, test_teardown 8 9 from django.utils import unittest 9 10 10 11 __all__ = ('DjangoTestRunner', 'DjangoTestSuiteRunner', 'run_tests') … … 226 227 self.failfast = failfast 227 228 228 229 def setup_test_environment(self, **kwargs): 229 setup_test_environment()230 test_setup.send(sender=self) 230 231 settings.DEBUG = False 231 232 unittest.installHandler() 232 233 … … 324 325 325 326 def teardown_test_environment(self, **kwargs): 326 327 unittest.removeHandler() 327 te ardown_test_environment()328 test_teardown.send(sender=self) 328 329 329 330 def suite_result(self, suite, result, **kwargs): 330 331 return len(result.failures) + len(result.errors) … … 348 349 349 350 Returns the number of tests that failed. 350 351 """ 352 suite = self.build_suite(test_labels, extra_tests) 351 353 self.setup_test_environment() 352 suite = self.build_suite(test_labels, extra_tests)353 354 old_config = self.setup_databases() 354 355 result = self.run_suite(suite) 355 356 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
60 60 return self.nodelist.render(context) 61 61 62 62 63 def setup_test_environment( ):63 def setup_test_environment(**kwargs): 64 64 """Perform any global pre-test setup. This involves: 65 65 66 66 - Installing the instrumented test renderer … … 76 76 mail.outbox = [] 77 77 78 78 deactivate() 79 signals.test_setup.connect(setup_test_environment) 79 80 80 81 def teardown_test_environment(): 81 def teardown_test_environment(**kwargs): 82 82 """Perform any global post-test teardown. This involves: 83 83 84 84 - Restoring the original test renderer … … 92 92 del mail.original_email_backend 93 93 94 94 del mail.outbox 95 signals.test_teardown.connect(teardown_test_environment) 95 96 96 97 97 98 def get_warnings_state():