[1.8.x] Combined TemplateTests and TemplateRegressionTests.
Backport of 32c108a221
from master
This commit is contained in:
parent
2e7414cdf4
commit
b22d20dd18
|
@ -22,9 +22,6 @@ class TemplateTests(SimpleTestCase):
|
||||||
template = Template('string template')
|
template = Template('string template')
|
||||||
self.assertEqual(template.origin.source, 'string template')
|
self.assertEqual(template.origin.source, 'string template')
|
||||||
|
|
||||||
|
|
||||||
class TemplateRegressionTests(SimpleTestCase):
|
|
||||||
|
|
||||||
@override_settings(SETTINGS_MODULE=None, DEBUG=True)
|
@override_settings(SETTINGS_MODULE=None, DEBUG=True)
|
||||||
def test_url_reverse_no_settings_module(self):
|
def test_url_reverse_no_settings_module(self):
|
||||||
# Regression test for #9005
|
# Regression test for #9005
|
||||||
|
@ -58,8 +55,8 @@ class TemplateRegressionTests(SimpleTestCase):
|
||||||
@override_settings(DEBUG=True)
|
@override_settings(DEBUG=True)
|
||||||
def test_no_wrapped_exception(self):
|
def test_no_wrapped_exception(self):
|
||||||
"""
|
"""
|
||||||
The template system doesn't wrap exceptions, but annotates them.
|
# 16770 -- The template system doesn't wrap exceptions, but annotates
|
||||||
Refs #16770
|
them.
|
||||||
"""
|
"""
|
||||||
c = Context({"coconuts": lambda: 42 / 0})
|
c = Context({"coconuts": lambda: 42 / 0})
|
||||||
t = Template("{{ coconuts }}")
|
t = Template("{{ coconuts }}")
|
||||||
|
@ -69,16 +66,20 @@ class TemplateRegressionTests(SimpleTestCase):
|
||||||
self.assertEqual(cm.exception.django_template_source[1], (0, 14))
|
self.assertEqual(cm.exception.django_template_source[1], (0, 14))
|
||||||
|
|
||||||
def test_invalid_block_suggestion(self):
|
def test_invalid_block_suggestion(self):
|
||||||
# See #7876
|
"""
|
||||||
try:
|
#7876 -- Error messages should include the unexpected block name.
|
||||||
|
"""
|
||||||
|
with self.assertRaises(TemplateSyntaxError) as e:
|
||||||
Template("{% if 1 %}lala{% endblock %}{% endif %}")
|
Template("{% if 1 %}lala{% endblock %}{% endif %}")
|
||||||
except TemplateSyntaxError as e:
|
|
||||||
self.assertEqual(e.args[0], "Invalid block tag: 'endblock', expected 'elif', 'else' or 'endif'")
|
self.assertEqual(
|
||||||
|
e.exception.args[0],
|
||||||
|
"Invalid block tag: 'endblock', expected 'elif', 'else' or 'endif'",
|
||||||
|
)
|
||||||
|
|
||||||
def test_super_errors(self):
|
def test_super_errors(self):
|
||||||
"""
|
"""
|
||||||
Test behavior of the raise errors into included blocks.
|
#18169 -- NoReverseMatch should not be silence in block.super.
|
||||||
See #18169
|
|
||||||
"""
|
"""
|
||||||
t = loader.get_template('included_content.html')
|
t = loader.get_template('included_content.html')
|
||||||
with self.assertRaises(urlresolvers.NoReverseMatch):
|
with self.assertRaises(urlresolvers.NoReverseMatch):
|
||||||
|
@ -86,7 +87,7 @@ class TemplateRegressionTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_debug_tag_non_ascii(self):
|
def test_debug_tag_non_ascii(self):
|
||||||
"""
|
"""
|
||||||
Test non-ASCII model representation in debug output (#23060).
|
#23060 -- Test non-ASCII model representation in debug output.
|
||||||
"""
|
"""
|
||||||
Group.objects.create(name="清風")
|
Group.objects.create(name="清風")
|
||||||
c1 = Context({"objs": Group.objects.all()})
|
c1 = Context({"objs": Group.objects.all()})
|
||||||
|
@ -95,7 +96,8 @@ class TemplateRegressionTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_extends_generic_template(self):
|
def test_extends_generic_template(self):
|
||||||
"""
|
"""
|
||||||
{% extends %} accepts django.template.backends.django.Template (#24338).
|
#24338 -- Allow extending django.template.backends.django.Template
|
||||||
|
objects.
|
||||||
"""
|
"""
|
||||||
parent = engines['django'].from_string(
|
parent = engines['django'].from_string(
|
||||||
'{% block content %}parent{% endblock %}')
|
'{% block content %}parent{% endblock %}')
|
||||||
|
|
Loading…
Reference in New Issue