mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Supported multiple template engines in render_to_string.
Adjusted its API through a deprecation path according to the DEP.
This commit is contained in:
@@ -153,13 +153,6 @@ class RenderToStringTest(SimpleTestCase):
|
||||
self.assertEqual(loader.render_to_string('test_context.html',
|
||||
{'obj': 'test'}), 'obj:test\n')
|
||||
|
||||
def test_existing_context_kept_clean(self):
|
||||
context = Context({'obj': 'before'})
|
||||
output = loader.render_to_string('test_context.html', {'obj': 'after'},
|
||||
context_instance=context)
|
||||
self.assertEqual(output, 'obj:after\n')
|
||||
self.assertEqual(context['obj'], 'before')
|
||||
|
||||
def test_empty_list(self):
|
||||
six.assertRaisesRegex(self, TemplateDoesNotExist,
|
||||
'No template names provided$',
|
||||
@@ -170,6 +163,21 @@ class RenderToStringTest(SimpleTestCase):
|
||||
'No template names provided$',
|
||||
loader.select_template, [])
|
||||
|
||||
|
||||
@override_settings(
|
||||
TEMPLATE_DIRS=(
|
||||
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
|
||||
)
|
||||
)
|
||||
class DeprecatedRenderToStringTest(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
|
||||
|
||||
def test_existing_context_kept_clean(self):
|
||||
context = Context({'obj': 'before'})
|
||||
output = loader.render_to_string('test_context.html', {'obj': 'after'},
|
||||
context_instance=context)
|
||||
self.assertEqual(output, 'obj:after\n')
|
||||
self.assertEqual(context['obj'], 'before')
|
||||
|
||||
def test_no_empty_dict_pushed_to_stack(self):
|
||||
"""
|
||||
No empty dict should be pushed to the context stack when render_to_string
|
||||
|
||||
Reference in New Issue
Block a user