Fixed #18995 -- Made blocktranslate tag raise TemplateSyntaxError when plural count is not a number.

This commit is contained in:
Jacob Walls 2020-09-26 15:03:13 -04:00 committed by Mariusz Felisiak
parent 848770dd2c
commit 01a7af09b9
2 changed files with 16 additions and 0 deletions

View file

@ -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 %}'