summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_load.py
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2015-05-08 15:10:36 -0500
committerPreston Timmons <prestontimmons@gmail.com>2015-05-21 09:12:06 -0500
commit655f52491505932ef04264de2bce21a03f3a7cd0 (patch)
treec38eca24b887466fc2385fc773ff34247567c732 /tests/template_tests/syntax_tests/test_load.py
parent7b8008a078ffdfd18ebbe78fecbb92cdddf2f304 (diff)
Fixed #17085, #24783 -- Refactored template library registration.
* Converted the ``libraries`` and ``builtins`` globals of ``django.template.base`` into properties of the Engine class. * Added a public API for explicit registration of libraries and builtins.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_load.py')
-rw-r--r--tests/template_tests/syntax_tests/test_load.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/template_tests/syntax_tests/test_load.py b/tests/template_tests/syntax_tests/test_load.py
index 711a9da632..919bbf1346 100644
--- a/tests/template_tests/syntax_tests/test_load.py
+++ b/tests/template_tests/syntax_tests/test_load.py
@@ -5,6 +5,10 @@ from ..utils import setup
class LoadTagTests(SimpleTestCase):
+ libraries = {
+ 'subpackage.echo': 'template_tests.templatetags.subpackage.echo',
+ 'testtags': 'template_tests.templatetags.testtags',
+ }
@setup({'load01': '{% load testtags subpackage.echo %}{% echo test %} {% echo2 "test" %}'})
def test_load01(self):
@@ -42,30 +46,30 @@ class LoadTagTests(SimpleTestCase):
# {% load %} tag errors
@setup({'load07': '{% load echo other_echo bad_tag from testtags %}'})
def test_load07(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "'bad_tag' is not a valid tag or filter in tag library 'testtags'"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('load07')
@setup({'load08': '{% load echo other_echo bad_tag from %}'})
def test_load08(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "'echo' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('load08')
@setup({'load09': '{% load from testtags %}'})
def test_load09(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "'from' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('load09')
@setup({'load10': '{% load echo from bad_library %}'})
def test_load10(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "'bad_library' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('load10')
- @setup({'load11': '{% load subpackage.echo_invalid %}'})
- def test_load11(self):
- with self.assertRaises(TemplateSyntaxError):
- self.engine.get_template('load11')
-
@setup({'load12': '{% load subpackage.missing %}'})
def test_load12(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "'subpackage.missing' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('load12')