diff options
| author | Preston Timmons <prestontimmons@gmail.com> | 2015-02-21 13:13:26 -0600 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@oscaro.com> | 2015-02-24 14:00:02 +0100 |
| commit | ff67ce5076c1f4d3dc32fd755a1b65d3310c6cb1 (patch) | |
| tree | 71487701bd58ec66ba05ae63d85b55bb7500d7a7 /tests/template_tests/test_custom.py | |
| parent | 06ffc764a9b2d2521e6a574d279b66ad411cc65c (diff) | |
Moved TemplateTagLoading cases into test_custom.
Diffstat (limited to 'tests/template_tests/test_custom.py')
| -rw-r--r-- | tests/template_tests/test_custom.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/template_tests/test_custom.py b/tests/template_tests/test_custom.py index 3e817254ee..2b70380825 100644 --- a/tests/template_tests/test_custom.py +++ b/tests/template_tests/test_custom.py @@ -1,10 +1,14 @@ from __future__ import unicode_literals +import os + from django.template import Context, Template, TemplateSyntaxError from django.test import SimpleTestCase, ignore_warnings +from django.test.utils import extend_sys_path from django.utils.deprecation import RemovedInDjango20Warning from .templatetags import custom, inclusion +from .utils import ROOT class CustomFilterTests(SimpleTestCase): @@ -276,3 +280,38 @@ class AssignmentTagTests(TagTestCase): ) with self.assertRaisesMessage(TemplateSyntaxError, msg): Template('{% load custom %}{% assignment_tag_without_context_parameter 123 as var %}') + + +class TemplateTagLoadingTests(SimpleTestCase): + + def setUp(self): + self.egg_dir = os.path.join(ROOT, 'eggs') + + def test_load_error(self): + ttext = "{% load broken_tag %}" + with self.assertRaises(TemplateSyntaxError) as e: + Template(ttext) + + self.assertIn('ImportError', e.exception.args[0]) + self.assertIn('Xtemplate', e.exception.args[0]) + + def test_load_error_egg(self): + ttext = "{% load broken_egg %}" + egg_name = '%s/tagsegg.egg' % self.egg_dir + with extend_sys_path(egg_name): + with self.assertRaises(TemplateSyntaxError): + with self.settings(INSTALLED_APPS=['tagsegg']): + Template(ttext) + try: + with self.settings(INSTALLED_APPS=['tagsegg']): + Template(ttext) + except TemplateSyntaxError as e: + self.assertIn('ImportError', e.args[0]) + self.assertIn('Xtemplate', e.args[0]) + + def test_load_working_egg(self): + ttext = "{% load working_egg %}" + egg_name = '%s/tagsegg.egg' % self.egg_dir + with extend_sys_path(egg_name): + with self.settings(INSTALLED_APPS=['tagsegg']): + Template(ttext) |
