mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Increased test coverage for various template tags.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from django.template import NodeList
|
||||
from django.template import NodeList, TemplateSyntaxError
|
||||
from django.template.base import Node
|
||||
from django.template.loader_tags import ExtendsNode
|
||||
from django.test import SimpleTestCase
|
||||
@@ -55,6 +55,9 @@ inheritance_templates = {
|
||||
'inheritance40': "{% extends 'inheritance33' %}{% block opt %}new{{ block.super }}{% endblock %}",
|
||||
'inheritance41': "{% extends 'inheritance36' %}{% block opt %}new{{ block.super }}{% endblock %}",
|
||||
'inheritance42': "{% extends 'inheritance02'|cut:' ' %}",
|
||||
'inheritance_empty': "{% extends %}",
|
||||
'extends_duplicate': "{% extends 'base.html' %}{% extends 'base.html' %}",
|
||||
'duplicate_block': "{% extends 'base.html' %}{% block content %}2{% endblock %}{% block content %}4{% endblock %}",
|
||||
}
|
||||
|
||||
|
||||
@@ -400,6 +403,23 @@ class InheritanceTests(SimpleTestCase):
|
||||
output = self.engine.render_to_string('inheritance42')
|
||||
self.assertEqual(output, '1234')
|
||||
|
||||
@setup(inheritance_templates)
|
||||
def test_inheritance_empty(self):
|
||||
with self.assertRaisesMessage(TemplateSyntaxError, "'extends' takes one argument"):
|
||||
self.engine.render_to_string('inheritance_empty')
|
||||
|
||||
@setup(inheritance_templates)
|
||||
def test_extends_duplicate(self):
|
||||
msg = "'extends' cannot appear more than once in the same template"
|
||||
with self.assertRaisesMessage(TemplateSyntaxError, msg):
|
||||
self.engine.render_to_string('extends_duplicate')
|
||||
|
||||
@setup(inheritance_templates)
|
||||
def test_duplicate_block(self):
|
||||
msg = "'block' tag with name 'content' appears more than once"
|
||||
with self.assertRaisesMessage(TemplateSyntaxError, msg):
|
||||
self.engine.render_to_string('duplicate_block')
|
||||
|
||||
|
||||
class ExtendsNodeTests(SimpleTestCase):
|
||||
def test_extends_node_repr(self):
|
||||
|
||||
Reference in New Issue
Block a user