summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_extends.py
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2018-03-24 21:38:20 +0100
committerTim Graham <timograham@gmail.com>2018-03-24 19:56:46 -0400
commit4554f9a783665d64b59c35b53ae71178e56ac783 (patch)
tree4281fbf14ba20f51fcc846441ccf86f72fe56e5f /tests/template_tests/syntax_tests/test_extends.py
parent623117d1f1d7866b7321f0e73a6c497bb3b3cb01 (diff)
Increased test coverage for various template tags.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_extends.py')
-rw-r--r--tests/template_tests/syntax_tests/test_extends.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/template_tests/syntax_tests/test_extends.py b/tests/template_tests/syntax_tests/test_extends.py
index 5b0b8d1811..0689838ae8 100644
--- a/tests/template_tests/syntax_tests/test_extends.py
+++ b/tests/template_tests/syntax_tests/test_extends.py
@@ -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):