Commit b885d029 by Chris Jerdonek

Moved some tests from test_template to test_renderengine.

parent 0ad0e95a
......@@ -89,3 +89,31 @@ class RenderEngineTestCase(unittest.TestCase):
def test_render_with_partial(self):
partials = {'partial': "{{person}}"}
self._assert_render('Hi Mom', 'Hi {{>partial}}', {'person': 'Mom'}, partials=partials)
def test_render__section_context_values(self):
"""
Test that escape and literal work on context values in sections.
"""
engine = self._engine()
engine.escape = lambda s: "**" + s
engine.literal = lambda s: s.upper()
template = '{{#test}}{{foo}} {{{foo}}}{{/test}}'
context = {'test': {'foo': 'bar'}}
self._assert_render('**bar BAR', template, context, engine=engine)
def test_render__partial_context_values(self):
"""
Test that escape and literal work on context values in partials.
"""
engine = self._engine()
engine.escape = lambda s: "**" + s
engine.literal = lambda s: s.upper()
partials = {'partial': '{{foo}} {{{foo}}}'}
self._assert_render('**bar BAR', '{{>partial}}', {'foo': 'bar'}, engine=engine, partials=partials)
......@@ -307,40 +307,6 @@ class TemplateTestCase(unittest.TestCase):
self.assertEquals(template.render(context), "Al: Hi; Bo: Hi; ")
def test_render__encoding_in_context_value(self):
template = Template('{{test}}')
context = {'test': "déf"}
template.decode_errors = 'ignore'
template.default_encoding = 'ascii'
self.assertEquals(template.render(context), "df")
template.default_encoding = 'utf_8'
self.assertEquals(template.render(context), u"déf")
def test_render__encoding_in_section_context_value(self):
template = Template('{{#test}}{{foo}}{{/test}}')
context = {'test': {'foo': "déf"}}
template.decode_errors = 'ignore'
template.default_encoding = 'ascii'
self.assertEquals(template.render(context), "df")
template.default_encoding = 'utf_8'
self.assertEquals(template.render(context), u"déf")
def test_render__encoding_in_partial_context_value(self):
load_template = lambda x: "{{foo}}"
template = Template('{{>partial}}', load_template=load_template)
context = {'foo': "déf"}
template.decode_errors = 'ignore'
template.default_encoding = 'ascii'
self.assertEquals(template.render(context), "df")
template.default_encoding = 'utf_8'
self.assertEquals(template.render(context), u"déf")
def test_render__nonascii_template(self):
"""
Test passing a non-unicode template with non-ascii characters.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment