Ticket #14319: new_test_signals_patch_3.diff
File new_test_signals_patch_3.diff, 4.2 KB (added by , 13 years ago) |
---|
-
docs/ref/signals.txt
504 504 The :class:`~django.template.Context` with which the template was 505 505 rendered. 506 506 507 test_setup 508 ---------- 509 510 .. data:: django.test.signals.test_setup 511 :module: 512 513 .. versionadded:: 1.4 514 515 Sent during global pre-test setup, just after applications have loaded and 516 the test suite has been built. This signal is not emitted during normal 517 operation. 518 519 Arguments sent with this signal: 520 521 sender 522 The :class:`~django.test.simple.DjangoTestSuiteRunner` object. 523 524 test_teardown 525 ------------- 526 527 .. data:: django.test.signals.test_teardown 528 :module: 529 530 .. versionadded:: 1.4 531 532 Sent during global post-test breakdown. This signal is not emitted during 533 normal operation. 534 535 Arguments sent with this signal: 536 537 sender 538 The :class:`~django.test.simple.DjangoTestSuiteRunner` object. 539 507 540 Database Wrappers 508 541 ================= 509 542 -
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
3 3 template_rendered = Signal(providing_args=["template", "context"]) 4 4 5 5 setting_changed = Signal(providing_args=["setting", "value"]) 6 7 test_setup = Signal() 8 test_teardown = Signal() -
django/test/utils.py
7 7 from django.conf import settings, UserSettingsHolder 8 8 from django.core import mail 9 9 from django.core.mail.backends import locmem 10 from django.test.signals import template_rendered, setting_changed 10 from django.test.signals import template_rendered, setting_changed, test_setup, test_teardown 11 11 from django.template import Template, loader, TemplateDoesNotExist 12 12 from django.template.loaders import cached 13 13 from django.utils.translation import deactivate … … 66 66 return self.nodelist.render(context) 67 67 68 68 69 def setup_test_environment( ):69 def setup_test_environment(**kwargs): 70 70 """Perform any global pre-test setup. This involves: 71 71 72 72 - Installing the instrumented test renderer … … 82 82 mail.outbox = [] 83 83 84 84 deactivate() 85 test_setup.connect(setup_test_environment) 85 86 86 87 def teardown_test_environment(): 87 def teardown_test_environment(**kwargs): 88 88 """Perform any global post-test teardown. This involves: 89 89 90 90 - Restoring the original test renderer … … 98 98 del mail.original_email_backend 99 99 100 100 del mail.outbox 101 test_teardown.connect(teardown_test_environment) 101 102 102 103 103 104 def get_warnings_state():