From 01a7af09b9d61aa66f5bf345fc32cc8f90ecb62a Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sat, 26 Sep 2020 15:03:13 -0400 Subject: Fixed #18995 -- Made blocktranslate tag raise TemplateSyntaxError when plural count is not a number. --- tests/template_tests/syntax_tests/i18n/test_blocktranslate.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/template_tests/syntax_tests') diff --git a/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py b/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py index 8edacd87e2..5079824b30 100644 --- a/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py +++ b/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py @@ -298,6 +298,15 @@ class I18nBlockTransTagTests(SimpleTestCase): with self.assertRaisesMessage(TemplateSyntaxError, msg): self.engine.render_to_string('template', {'a': [1, 2, 3]}) + @setup({'template': ( + '{% load i18n %}{% blocktranslate count counter=num %}{{ counter }}' + '{% plural %}{{ counter }}{% endblocktranslate %}' + )}) + def test_count_not_number(self, tag_name): + msg = "'counter' argument to '{}' tag must be a number.".format(tag_name) + with self.assertRaisesMessage(TemplateSyntaxError, msg): + self.engine.render_to_string('template', {'num': '1'}) + @setup({'template': ( '{% load i18n %}{% blocktranslate count count=var|length %}' 'There is {{ count }} object. {% block a %} {% endblock %}' -- cgit v1.3