diff options
| author | Mads Jensen <mje@inducks.org> | 2017-10-02 17:02:58 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-10-02 11:02:58 -0400 |
| commit | aba3467585a43236e9f8b97bffb5d77911b9caf6 (patch) | |
| tree | 1b12a9456fed331011222a0b3bfd2899e7734b8f /tests/template_tests/syntax_tests | |
| parent | 3fb1ad9505fa28ec9c89039fbba40f6ebea8bf8e (diff) | |
Added tests for invalid {% autoescape %} usage.
Diffstat (limited to 'tests/template_tests/syntax_tests')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_autoescape.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_autoescape.py b/tests/template_tests/syntax_tests/test_autoescape.py index 35debd5269..810731978b 100644 --- a/tests/template_tests/syntax_tests/test_autoescape.py +++ b/tests/template_tests/syntax_tests/test_autoescape.py @@ -123,3 +123,15 @@ class AutoescapeTagTests(SimpleTestCase): """ output = self.engine.render_to_string('autoescape-lookup01', {'var': {'key': 'this & that'}}) self.assertEqual(output, 'this & that') + + @setup({'autoescape-incorrect-arg': '{% autoescape true %}{{ var.key }}{% endautoescape %}'}) + def test_invalid_arg(self): + msg = "'autoescape' argument should be 'on' or 'off'" + with self.assertRaisesMessage(TemplateSyntaxError, msg): + self.engine.render_to_string('autoescape-incorrect-arg', {'var': {'key': 'this & that'}}) + + @setup({'autoescape-incorrect-arg': '{% autoescape %}{{ var.key }}{% endautoescape %}'}) + def test_no_arg(self): + msg = "'autoescape' tag requires exactly one argument." + with self.assertRaisesMessage(TemplateSyntaxError, msg): + self.engine.render_to_string('autoescape-incorrect-arg', {'var': {'key': 'this & that'}}) |
