summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_cache.py
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2015-04-11 19:41:45 -0400
committerPreston Timmons <prestontimmons@gmail.com>2015-04-20 09:11:37 -0500
commitfb267a1d85c22924231be8cec6c58c42ae57913f (patch)
treed85f9285bea1c37d7af83ebc5c84996d2e9d51dd /tests/template_tests/syntax_tests/test_cache.py
parentd84f01ff08922c70f9bb0861846c8ace0764b2dc (diff)
Updated template tests to create their own engine.
This continues work to treat Django templates as a library.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_cache.py')
-rw-r--r--tests/template_tests/syntax_tests/test_cache.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/template_tests/syntax_tests/test_cache.py b/tests/template_tests/syntax_tests/test_cache.py
index 1742b7111c..f088510d5d 100644
--- a/tests/template_tests/syntax_tests/test_cache.py
+++ b/tests/template_tests/syntax_tests/test_cache.py
@@ -1,5 +1,5 @@
from django.core.cache import cache
-from django.template import Context, Template, TemplateSyntaxError
+from django.template import Context, Engine, TemplateSyntaxError
from django.test import SimpleTestCase, override_settings
from ..utils import setup
@@ -119,8 +119,13 @@ class CacheTagTests(SimpleTestCase):
class CacheTests(SimpleTestCase):
+ @classmethod
+ def setUpClass(cls):
+ cls.engine = Engine()
+ super(CacheTests, cls).setUpClass()
+
def test_cache_regression_20130(self):
- t = Template('{% load cache %}{% cache 1 regression_20130 %}foo{% endcache %}')
+ t = self.engine.from_string('{% load cache %}{% cache 1 regression_20130 %}foo{% endcache %}')
cachenode = t.nodelist[1]
self.assertEqual(cachenode.fragment_name, 'regression_20130')
@@ -139,8 +144,8 @@ class CacheTests(SimpleTestCase):
When a cache called "template_fragments" is present, the cache tag
will use it in preference to 'default'
"""
- t1 = Template('{% load cache %}{% cache 1 fragment %}foo{% endcache %}')
- t2 = Template('{% load cache %}{% cache 1 fragment using="default" %}bar{% endcache %}')
+ t1 = self.engine.from_string('{% load cache %}{% cache 1 fragment %}foo{% endcache %}')
+ t2 = self.engine.from_string('{% load cache %}{% cache 1 fragment using="default" %}bar{% endcache %}')
ctx = Context()
o1 = t1.render(ctx)
@@ -154,7 +159,7 @@ class CacheTests(SimpleTestCase):
When a cache that doesn't exist is specified, the cache tag will
raise a TemplateSyntaxError
'"""
- t = Template('{% load cache %}{% cache 1 backend using="unknown" %}bar{% endcache %}')
+ t = self.engine.from_string('{% load cache %}{% cache 1 backend using="unknown" %}bar{% endcache %}')
ctx = Context()
with self.assertRaises(TemplateSyntaxError):