diff options
Diffstat (limited to 'tests/template_tests/syntax_tests')
13 files changed, 33 insertions, 11 deletions
diff --git a/tests/template_tests/syntax_tests/test_cache.py b/tests/template_tests/syntax_tests/test_cache.py index f088510d5d..2039e7808c 100644 --- a/tests/template_tests/syntax_tests/test_cache.py +++ b/tests/template_tests/syntax_tests/test_cache.py @@ -6,6 +6,10 @@ from ..utils import setup class CacheTagTests(SimpleTestCase): + libraries = { + 'cache': 'django.templatetags.cache', + 'custom': 'template_tests.templatetags.custom', + } def tearDown(self): cache.clear() @@ -121,7 +125,7 @@ class CacheTests(SimpleTestCase): @classmethod def setUpClass(cls): - cls.engine = Engine() + cls.engine = Engine(libraries={'cache': 'django.templatetags.cache'}) super(CacheTests, cls).setUpClass() def test_cache_regression_20130(self): diff --git a/tests/template_tests/syntax_tests/test_cycle.py b/tests/template_tests/syntax_tests/test_cycle.py index e2edf94c8d..c478faff52 100644 --- a/tests/template_tests/syntax_tests/test_cycle.py +++ b/tests/template_tests/syntax_tests/test_cycle.py @@ -6,6 +6,7 @@ from ..utils import setup class CycleTagTests(SimpleTestCase): + libraries = {'future': 'django.templatetags.future'} @setup({'cycle01': '{% cycle a %}'}) def test_cycle01(self): diff --git a/tests/template_tests/syntax_tests/test_extends.py b/tests/template_tests/syntax_tests/test_extends.py index 1b0ff36a3c..3e65f4bf90 100644 --- a/tests/template_tests/syntax_tests/test_extends.py +++ b/tests/template_tests/syntax_tests/test_extends.py @@ -56,6 +56,7 @@ inheritance_templates = { class InheritanceTests(SimpleTestCase): + libraries = {'testtags': 'template_tests.templatetags.testtags'} @setup(inheritance_templates) def test_inheritance01(self): diff --git a/tests/template_tests/syntax_tests/test_firstof.py b/tests/template_tests/syntax_tests/test_firstof.py index a3c8c83151..79eb381c69 100644 --- a/tests/template_tests/syntax_tests/test_firstof.py +++ b/tests/template_tests/syntax_tests/test_firstof.py @@ -6,6 +6,7 @@ from ..utils import setup class FirstOfTagTests(SimpleTestCase): + libraries = {'future': 'django.templatetags.future'} @setup({'firstof01': '{% firstof a b c %}'}) def test_firstof01(self): diff --git a/tests/template_tests/syntax_tests/test_for.py b/tests/template_tests/syntax_tests/test_for.py index 566b86f3d8..8045ea4990 100644 --- a/tests/template_tests/syntax_tests/test_for.py +++ b/tests/template_tests/syntax_tests/test_for.py @@ -6,6 +6,7 @@ from ..utils import setup class ForTagTests(SimpleTestCase): + libraries = {'custom': 'template_tests.templatetags.custom'} @setup({'for-tag01': '{% for val in values %}{{ val }}{% endfor %}'}) def test_for_tag01(self): diff --git a/tests/template_tests/syntax_tests/test_i18n.py b/tests/template_tests/syntax_tests/test_i18n.py index da53a8c279..1d0f83478a 100644 --- a/tests/template_tests/syntax_tests/test_i18n.py +++ b/tests/template_tests/syntax_tests/test_i18n.py @@ -10,6 +10,10 @@ from ..utils import setup class I18nTagTests(SimpleTestCase): + libraries = { + 'custom': 'template_tests.templatetags.custom', + 'i18n': 'django.templatetags.i18n', + } @setup({'i18n01': '{% load i18n %}{% trans \'xxxyyyxxx\' %}'}) def test_i18n01(self): diff --git a/tests/template_tests/syntax_tests/test_if_changed.py b/tests/template_tests/syntax_tests/test_if_changed.py index 62f9563020..09cdc34a88 100644 --- a/tests/template_tests/syntax_tests/test_if_changed.py +++ b/tests/template_tests/syntax_tests/test_if_changed.py @@ -5,6 +5,7 @@ from ..utils import setup class IfChangedTagTests(SimpleTestCase): + libraries = {'custom': 'template_tests.templatetags.custom'} @setup({'ifchanged01': '{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}'}) def test_ifchanged01(self): diff --git a/tests/template_tests/syntax_tests/test_include.py b/tests/template_tests/syntax_tests/test_include.py index 5a05b32c33..fc1554a17e 100644 --- a/tests/template_tests/syntax_tests/test_include.py +++ b/tests/template_tests/syntax_tests/test_include.py @@ -13,6 +13,7 @@ include_fail_templates = { class IncludeTagTests(SimpleTestCase): + libraries = {'bad_tag': 'template_tests.templatetags.bad_tag'} @setup({'include01': '{% include "basic-syntax01" %}'}, basic_templates) def test_include01(self): diff --git a/tests/template_tests/syntax_tests/test_invalid_string.py b/tests/template_tests/syntax_tests/test_invalid_string.py index 2bb8c71fd1..18520aa7bf 100644 --- a/tests/template_tests/syntax_tests/test_invalid_string.py +++ b/tests/template_tests/syntax_tests/test_invalid_string.py @@ -4,6 +4,7 @@ from ..utils import setup class InvalidStringTests(SimpleTestCase): + libraries = {'i18n': 'django.templatetags.i18n'} @setup({'invalidstr01': '{{ var|default:"Foo" }}'}) def test_invalidstr01(self): 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') diff --git a/tests/template_tests/syntax_tests/test_simple_tag.py b/tests/template_tests/syntax_tests/test_simple_tag.py index b89af4c72b..5e6ce4733e 100644 --- a/tests/template_tests/syntax_tests/test_simple_tag.py +++ b/tests/template_tests/syntax_tests/test_simple_tag.py @@ -5,6 +5,7 @@ from ..utils import setup class SimpleTagTests(SimpleTestCase): + libraries = {'custom': 'template_tests.templatetags.custom'} @setup({'simpletag-renamed01': '{% load custom %}{% minusone 7 %}'}) def test_simpletag_renamed01(self): diff --git a/tests/template_tests/syntax_tests/test_static.py b/tests/template_tests/syntax_tests/test_static.py index b646ac2bb8..8ff90f5a5c 100644 --- a/tests/template_tests/syntax_tests/test_static.py +++ b/tests/template_tests/syntax_tests/test_static.py @@ -7,6 +7,7 @@ from ..utils import setup @override_settings(MEDIA_URL="/media/", STATIC_URL="/static/") class StaticTagTests(SimpleTestCase): + libraries = {'static': 'django.templatetags.static'} @setup({'static-prefixtag01': '{% load static %}{% get_static_prefix %}'}) def test_static_prefixtag01(self): diff --git a/tests/template_tests/syntax_tests/test_width_ratio.py b/tests/template_tests/syntax_tests/test_width_ratio.py index 9799b7d6ab..8206b83c58 100644 --- a/tests/template_tests/syntax_tests/test_width_ratio.py +++ b/tests/template_tests/syntax_tests/test_width_ratio.py @@ -6,6 +6,7 @@ from ..utils import setup class WidthRatioTagTests(SimpleTestCase): + libraries = {'custom': 'template_tests.templatetags.custom'} @setup({'widthratio01': '{% widthratio a b 0 %}'}) def test_widthratio01(self): |
