summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-09-03 09:06:33 -0400
committerGitHub <noreply@github.com>2016-09-03 09:06:33 -0400
commit277fe2e8f2ee35cd389b079ce7691491bb5738ec (patch)
tree22f68b9207297232dc65dccbd2c958ff19f89fa3 /tests
parent2ced2f785d5aca0354abf5841d5449b7a49509dc (diff)
Fixed #25788 -- Enabled the cached template loader if debug is False.
Diffstat (limited to 'tests')
-rw-r--r--tests/template_backends/test_django.py15
-rw-r--r--tests/template_loader/tests.py5
-rw-r--r--tests/template_tests/test_loaders.py2
3 files changed, 20 insertions, 2 deletions
diff --git a/tests/template_backends/test_django.py b/tests/template_backends/test_django.py
index 1a93a82274..a474b0765f 100644
--- a/tests/template_backends/test_django.py
+++ b/tests/template_backends/test_django.py
@@ -130,3 +130,18 @@ class DjangoTemplatesTests(TemplateStringsTests):
engines['django'].from_string('Hello, {{ name }}').render({'name': 'Bob & Jim'}),
'Hello, Bob &amp; Jim'
)
+
+ default_loaders = [
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ ]
+
+ @override_settings(DEBUG=False)
+ def test_non_debug_default_template_loaders(self):
+ engine = DjangoTemplates({'DIRS': [], 'APP_DIRS': True, 'NAME': 'django', 'OPTIONS': {}})
+ self.assertEqual(engine.engine.loaders, [('django.template.loaders.cached.Loader', self.default_loaders)])
+
+ @override_settings(DEBUG=True)
+ def test_debug_default_template_loaders(self):
+ engine = DjangoTemplates({'DIRS': [], 'APP_DIRS': True, 'NAME': 'django', 'OPTIONS': {}})
+ self.assertEqual(engine.engine.loaders, self.default_loaders)
diff --git a/tests/template_loader/tests.py b/tests/template_loader/tests.py
index 5e62574666..c3bb444175 100644
--- a/tests/template_loader/tests.py
+++ b/tests/template_loader/tests.py
@@ -11,11 +11,14 @@ from django.test.client import RequestFactory
'APP_DIRS': True,
}, {
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
],
+ 'loaders': [
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ ]
},
}])
class TemplateLoaderTests(SimpleTestCase):
diff --git a/tests/template_tests/test_loaders.py b/tests/template_tests/test_loaders.py
index 1a1457142d..0cb1b9ee36 100644
--- a/tests/template_tests/test_loaders.py
+++ b/tests/template_tests/test_loaders.py
@@ -279,7 +279,7 @@ class FileSystemLoaderTests(SimpleTestCase):
@classmethod
def setUpClass(cls):
- cls.engine = Engine(dirs=[TEMPLATE_DIR])
+ cls.engine = Engine(dirs=[TEMPLATE_DIR], loaders=['django.template.loaders.filesystem.Loader'])
super(FileSystemLoaderTests, cls).setUpClass()
@contextmanager