From 77aa74cb70dd85497dbade6bc0f394aa41e88c94 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 7 Nov 2019 01:26:22 -0800 Subject: Refs #29983 -- Added support for using pathlib.Path in all settings. --- tests/template_backends/test_django.py | 12 ++++++++++++ tests/template_backends/test_jinja2.py | 11 +++++++++++ 2 files changed, 23 insertions(+) (limited to 'tests/template_backends') 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!') -- cgit v1.2.1