Loading django/template/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -564,7 +564,7 @@ class Parser(object): "forget to register or load this tag?" % ( token.lineno, command, get_text_list(["'%s'" % p for p in parse_until]), get_text_list(["'%s'" % p for p in parse_until], 'or'), ), ) raise self.error( Loading tests/template_tests/tests.py +6 −3 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ from django.template import Context, Engine, TemplateSyntaxError from django.template.base import UNKNOWN_SOURCE from django.test import SimpleTestCase, override_settings from django.urls import NoReverseMatch from django.utils import translation class TemplateTests(SimpleTestCase): Loading Loading @@ -64,13 +65,15 @@ class TemplateTests(SimpleTestCase): def test_invalid_block_suggestion(self): """ #7876 -- Error messages should include the unexpected block name. Error messages should include the unexpected block name and be in all English. """ engine = Engine() msg = ( "Invalid block tag on line 1: 'endblock', expected 'elif', 'else' " "or 'endif'. Did you forget to register or load this tag?" ) with self.settings(USE_I18N=True), translation.override('de'): with self.assertRaisesMessage(TemplateSyntaxError, msg): engine.from_string("{% if 1 %}lala{% endblock %}{% endif %}") Loading Loading
django/template/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -564,7 +564,7 @@ class Parser(object): "forget to register or load this tag?" % ( token.lineno, command, get_text_list(["'%s'" % p for p in parse_until]), get_text_list(["'%s'" % p for p in parse_until], 'or'), ), ) raise self.error( Loading
tests/template_tests/tests.py +6 −3 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ from django.template import Context, Engine, TemplateSyntaxError from django.template.base import UNKNOWN_SOURCE from django.test import SimpleTestCase, override_settings from django.urls import NoReverseMatch from django.utils import translation class TemplateTests(SimpleTestCase): Loading Loading @@ -64,13 +65,15 @@ class TemplateTests(SimpleTestCase): def test_invalid_block_suggestion(self): """ #7876 -- Error messages should include the unexpected block name. Error messages should include the unexpected block name and be in all English. """ engine = Engine() msg = ( "Invalid block tag on line 1: 'endblock', expected 'elif', 'else' " "or 'endif'. Did you forget to register or load this tag?" ) with self.settings(USE_I18N=True), translation.override('de'): with self.assertRaisesMessage(TemplateSyntaxError, msg): engine.from_string("{% if 1 %}lala{% endblock %}{% endif %}") Loading