diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-17 07:11:37 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-17 07:11:37 +0000 |
| commit | bccb8897e6ab0fe8d2e5b9bcb725ac28b1c8e566 (patch) | |
| tree | d3abbbdf27fa5ae3c78a9dc510798cd521e46684 /django/test/utils.py | |
| parent | 44dd91ec6d39525e52b78f7fff6de8531b980f5f (diff) | |
Fixed #4565 -- Changed template rendering to use iterators, rather than
creating large strings, as much as possible. This is all backwards compatible.
Thanks, Brian Harring.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5482 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/test/utils.py')
| -rw-r--r-- | django/test/utils.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/django/test/utils.py b/django/test/utils.py index f5122fa96d..303a223183 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -11,12 +11,21 @@ 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. @@ -44,7 +53,9 @@ 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 @@ -59,7 +70,8 @@ def teardown_test_environment(): """ Template.render = Template.original_render - del Template.original_render + Template.iter_render = Template.original_iter_render + del Template.original_render, Template.original_iter_render mail.SMTPConnection = mail.original_SMTPConnection del mail.original_SMTPConnection |
