1
0
mirror of https://github.com/django/django.git synced 2025-02-02 05:40:39 +00:00

Fixed #26403 -- Removed translated content in "Invalid block tag" message.

This commit is contained in:
amureki 2016-04-03 10:02:20 +02:00 committed by Tim Graham
parent c12a00e554
commit f8bbba8060
2 changed files with 7 additions and 4 deletions

View File

@ -564,7 +564,7 @@ class Parser(object):
"forget to register or load this tag?" % ( "forget to register or load this tag?" % (
token.lineno, token.lineno,
command, 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( raise self.error(

View File

@ -8,6 +8,7 @@ from django.template import Context, Engine, TemplateSyntaxError
from django.template.base import UNKNOWN_SOURCE from django.template.base import UNKNOWN_SOURCE
from django.test import SimpleTestCase, override_settings from django.test import SimpleTestCase, override_settings
from django.urls import NoReverseMatch from django.urls import NoReverseMatch
from django.utils import translation
class TemplateTests(SimpleTestCase): class TemplateTests(SimpleTestCase):
@ -64,15 +65,17 @@ class TemplateTests(SimpleTestCase):
def test_invalid_block_suggestion(self): 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() engine = Engine()
msg = ( msg = (
"Invalid block tag on line 1: 'endblock', expected 'elif', 'else' " "Invalid block tag on line 1: 'endblock', expected 'elif', 'else' "
"or 'endif'. Did you forget to register or load this tag?" "or 'endif'. Did you forget to register or load this tag?"
) )
with self.assertRaisesMessage(TemplateSyntaxError, msg): with self.settings(USE_I18N=True), translation.override('de'):
engine.from_string("{% if 1 %}lala{% endblock %}{% endif %}") with self.assertRaisesMessage(TemplateSyntaxError, msg):
engine.from_string("{% if 1 %}lala{% endblock %}{% endif %}")
def test_unknown_block_tag(self): def test_unknown_block_tag(self):
engine = Engine() engine = Engine()