diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-12-08 11:13:52 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-12-08 11:13:52 +0100 |
| commit | c91667338a4e774e2819ccf4da852dc7b759bc19 (patch) | |
| tree | 42a700d237c85ac2b647999d02d3dcd7d8047068 /tests/regressiontests/templates | |
| parent | 53b879f045f0e55cc8f4bedff67b5a14f3057561 (diff) | |
Fixed #19357 -- Allow non-ASCII chars in filesystem paths
Thanks kujiu for the report and Aymeric Augustin for the review.
Diffstat (limited to 'tests/regressiontests/templates')
| -rw-r--r-- | tests/regressiontests/templates/loaders.py | 7 | ||||
| -rw-r--r-- | tests/regressiontests/templates/response.py | 3 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 7 |
3 files changed, 10 insertions, 7 deletions
diff --git a/tests/regressiontests/templates/loaders.py b/tests/regressiontests/templates/loaders.py index 7fbb0841f9..b77965203f 100644 --- a/tests/regressiontests/templates/loaders.py +++ b/tests/regressiontests/templates/loaders.py @@ -18,6 +18,7 @@ from django.template import TemplateDoesNotExist, Context from django.template.loaders.eggs import Loader as EggLoader from django.template import loader from django.utils import unittest, six +from django.utils._os import upath from django.utils.six import StringIO @@ -111,9 +112,9 @@ class CachedLoader(unittest.TestCase): def test_templatedir_caching(self): "Check that the template directories form part of the template cache key. Refs #13573" # Retrive a template specifying a template directory to check - t1, name = loader.find_template('test.html', (os.path.join(os.path.dirname(__file__), 'templates', 'first'),)) + t1, name = loader.find_template('test.html', (os.path.join(os.path.dirname(upath(__file__)), 'templates', 'first'),)) # Now retrieve the same template name, but from a different directory - t2, name = loader.find_template('test.html', (os.path.join(os.path.dirname(__file__), 'templates', 'second'),)) + t2, name = loader.find_template('test.html', (os.path.join(os.path.dirname(upath(__file__)), 'templates', 'second'),)) # The two templates should not have the same content self.assertNotEqual(t1.render(Context({})), t2.render(Context({}))) @@ -123,7 +124,7 @@ class RenderToStringTest(unittest.TestCase): def setUp(self): self._old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS settings.TEMPLATE_DIRS = ( - os.path.join(os.path.dirname(__file__), 'templates'), + os.path.join(os.path.dirname(upath(__file__)), 'templates'), ) def tearDown(self): diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py index a2a76a3310..c4da50af6b 100644 --- a/tests/regressiontests/templates/response.py +++ b/tests/regressiontests/templates/response.py @@ -11,6 +11,7 @@ from django.template import Template, Context from django.template.response import (TemplateResponse, SimpleTemplateResponse, ContentNotRenderedError) from django.test.utils import override_settings +from django.utils._os import upath def test_processor(request): return {'processors': 'yes'} @@ -206,7 +207,7 @@ class SimpleTemplateResponseTest(TestCase): @override_settings( TEMPLATE_CONTEXT_PROCESSORS=[test_processor_name], - TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__),'templates')), + TEMPLATE_DIRS=(os.path.join(os.path.dirname(upath(__file__)), 'templates')), ) class TemplateResponseTest(TestCase): diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 65d6e727e1..9ec487d06c 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -30,6 +30,7 @@ from django.test.utils import (setup_test_template_loader, from django.utils import unittest from django.utils.encoding import python_2_unicode_compatible from django.utils.formats import date_format +from django.utils._os import upath from django.utils.translation import activate, deactivate, ugettext as _ from django.utils.safestring import mark_safe from django.utils import six @@ -423,7 +424,7 @@ class Templates(TestCase): # Set ALLOWED_INCLUDE_ROOTS so that ssi works. old_allowed_include_roots = settings.ALLOWED_INCLUDE_ROOTS settings.ALLOWED_INCLUDE_ROOTS = ( - os.path.dirname(os.path.abspath(__file__)), + os.path.dirname(os.path.abspath(upath(__file__))), ) # Warm the URL reversing cache. This ensures we don't pay the cost @@ -514,7 +515,7 @@ class Templates(TestCase): def get_template_tests(self): # SYNTAX -- # 'template_name': ('template contents', 'context dict', 'expected string output' or Exception class) - basedir = os.path.dirname(os.path.abspath(__file__)) + basedir = os.path.dirname(os.path.abspath(upath(__file__))) tests = { ### BASIC SYNTAX ################################################ @@ -1649,7 +1650,7 @@ class TemplateTagLoading(unittest.TestCase): def setUp(self): self.old_path = sys.path[:] self.old_apps = settings.INSTALLED_APPS - self.egg_dir = '%s/eggs' % os.path.dirname(__file__) + self.egg_dir = '%s/eggs' % os.path.dirname(upath(__file__)) self.old_tag_modules = template_base.templatetags_modules template_base.templatetags_modules = [] |
