From: Erik Johnson Date: Mon, 19 Mar 2018 19:18:27 +0000 (-0500) Subject: Add test cases for quotes and expand coverage to include Markup input X-Git-Tag: 2.11.0~122^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=863558131ca99abb7ba0aa0ebb6777c173b34549;p=thirdparty%2Fjinja.git Add test cases for quotes and expand coverage to include Markup input --- diff --git a/tests/test_filters.py b/tests/test_filters.py index 8962ced3..eee5d35a 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -135,17 +135,22 @@ class TestFilter(object): out = tmpl.render() assert out == 'a|b' - def test_indent(self, env): - text = '\n'.join(['', 'foo bar', '']) + @staticmethod + def _test_indent_multiline_template(env, markup=False): + text = '\n'.join(['', 'foo bar', '"baz"', '']) + if markup: + text = Markup(text) t = env.from_string('{{ foo|indent(2, false, false) }}') - assert t.render(foo=text) == '\n foo bar\n' + assert t.render(foo=text) == '\n foo bar\n "baz"\n' t = env.from_string('{{ foo|indent(2, false, true) }}') - assert t.render(foo=text) == '\n foo bar\n ' + assert t.render(foo=text) == '\n foo bar\n "baz"\n ' t = env.from_string('{{ foo|indent(2, true, false) }}') - assert t.render(foo=text) == ' \n foo bar\n' + assert t.render(foo=text) == ' \n foo bar\n "baz"\n' t = env.from_string('{{ foo|indent(2, true, true) }}') - assert t.render(foo=text) == ' \n foo bar\n ' + assert t.render(foo=text) == ' \n foo bar\n "baz"\n ' + def test_indent(self, env): + self._test_indent_multiline_template(env) t = env.from_string('{{ "jinja"|indent }}') assert t.render() == 'jinja' t = env.from_string('{{ "jinja"|indent(first=true) }}') @@ -153,6 +158,12 @@ class TestFilter(object): t = env.from_string('{{ "jinja"|indent(blank=true) }}') assert t.render() == 'jinja' + def test_indent_markup_input(self, env): + ''' + Tests casses where the filter input is a Markup type + ''' + self._test_indent_multiline_template(env, markup=True) + def test_indentfirst_deprecated(self, env): with pytest.warns(DeprecationWarning): env.from_string('{{ "jinja"|indent(indentfirst=true) }}').render()