diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-11-07 01:26:22 -0800 |
---|---|---|
committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-11-07 10:26:22 +0100 |
commit | 77aa74cb70dd85497dbade6bc0f394aa41e88c94 (patch) | |
tree | f526b5e63897415e8753c6e38396bba535e3fc75 /tests/template_backends | |
parent | 367634f976ab43db93321bf4eb898449b670e291 (diff) | |
download | django-77aa74cb70dd85497dbade6bc0f394aa41e88c94.tar.gz |
Refs #29983 -- Added support for using pathlib.Path in all settings.
Diffstat (limited to 'tests/template_backends')
-rw-r--r-- | tests/template_backends/test_django.py | 12 | ||||
-rw-r--r-- | tests/template_backends/test_jinja2.py | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/template_backends/test_django.py b/tests/template_backends/test_django.py index e7a4a03546..6f5035c741 100644 --- a/tests/template_backends/test_django.py +++ b/tests/template_backends/test_django.py @@ -1,3 +1,5 @@ +from pathlib import Path + from template_tests.test_response import test_processor_name from django.template import Context, EngineHandler, RequestContext @@ -164,3 +166,13 @@ class DjangoTemplatesTests(TemplateStringsTests): def test_debug_default_template_loaders(self): engine = DjangoTemplates({'DIRS': [], 'APP_DIRS': True, 'NAME': 'django', 'OPTIONS': {}}) self.assertEqual(engine.engine.loaders, self.default_loaders) + + def test_dirs_pathlib(self): + engine = DjangoTemplates({ + 'DIRS': [Path(__file__).parent / 'templates' / 'template_backends'], + 'APP_DIRS': False, + 'NAME': 'django', + 'OPTIONS': {}, + }) + template = engine.get_template('hello.html') + self.assertEqual(template.render({'name': 'Joe'}), 'Hello Joe!\n') diff --git a/tests/template_backends/test_jinja2.py b/tests/template_backends/test_jinja2.py index 117719fa0d..a454e93a39 100644 --- a/tests/template_backends/test_jinja2.py +++ b/tests/template_backends/test_jinja2.py @@ -1,3 +1,4 @@ +from pathlib import Path from unittest import skipIf from django.template import TemplateSyntaxError @@ -85,3 +86,13 @@ class Jinja2Tests(TemplateStringsTests): with self.settings(STATIC_URL='/s/'): content = template.render(request=request) self.assertEqual(content, 'Static URL: /s/') + + def test_dirs_pathlib(self): + engine = Jinja2({ + 'DIRS': [Path(__file__).parent / 'templates' / 'template_backends'], + 'APP_DIRS': False, + 'NAME': 'jinja2', + 'OPTIONS': {}, + }) + template = engine.get_template('hello.html') + self.assertEqual(template.render({'name': 'Joe'}), 'Hello Joe!') |