1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Backed out the changes in [5482] for a bit whilst some more investigation into

side-effects is done. Refs #4565.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2007-06-22 07:15:04 +00:00
parent dbebf54d6c
commit 880e3cfaa6
21 changed files with 162 additions and 284 deletions

View File

@@ -11,21 +11,12 @@ from django.template import Template
TEST_DATABASE_PREFIX = 'test_'
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test system Client.
"""An instrumented Template render method, providing a signal
that can be intercepted by the test system Client
"""
dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context)
return self.nodelist.render(context)
def instrumented_test_iter_render(self, context):
"""
An instrumented Template iter_render method, providing a signal that can be
intercepted by the test system Client.
"""
for chunk in self.nodelist.iter_render(context):
yield chunk
dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context)
class TestSMTPConnection(object):
"""A substitute SMTP connection for use during test sessions.
@@ -53,9 +44,7 @@ def setup_test_environment():
"""
Template.original_render = Template.render
Template.original_iter_render = Template.iter_render
Template.render = instrumented_test_render
Template.iter_render = instrumented_test_render
mail.original_SMTPConnection = mail.SMTPConnection
mail.SMTPConnection = TestSMTPConnection
@@ -70,8 +59,7 @@ def teardown_test_environment():
"""
Template.render = Template.original_render
Template.iter_render = Template.original_iter_render
del Template.original_render, Template.original_iter_render
del Template.original_render
mail.SMTPConnection = mail.original_SMTPConnection
del mail.original_SMTPConnection