From c91667338a4e774e2819ccf4da852dc7b759bc19 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 8 Dec 2012 11:13:52 +0100 Subject: Fixed #19357 -- Allow non-ASCII chars in filesystem paths Thanks kujiu for the report and Aymeric Augustin for the review. --- tests/regressiontests/admin_scripts/tests.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tests/regressiontests/admin_scripts/tests.py') diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index a26d7a6eaa..d0ca9d26df 100644 --- a/tests/regressiontests/admin_scripts/tests.py +++ b/tests/regressiontests/admin_scripts/tests.py @@ -19,13 +19,15 @@ from django.conf import settings from django.db import connection from django.test.simple import DjangoTestSuiteRunner from django.utils import unittest +from django.utils.encoding import force_str, force_text +from django.utils._os import upath from django.test import LiveServerTestCase -test_dir = os.path.dirname(os.path.dirname(__file__)) +test_dir = os.path.dirname(os.path.dirname(upath(__file__))) class AdminScriptTestCase(unittest.TestCase): def write_settings(self, filename, apps=None, is_dir=False, sdict=None): - test_dir = os.path.dirname(os.path.dirname(__file__)) + test_dir = os.path.dirname(os.path.dirname(upath(__file__))) if is_dir: settings_dir = os.path.join(test_dir, filename) os.mkdir(settings_dir) @@ -94,6 +96,7 @@ class AdminScriptTestCase(unittest.TestCase): return paths def run_test(self, script, args, settings_file=None, apps=None): + test_dir = os.path.dirname(os.path.dirname(__file__)) project_dir = os.path.dirname(test_dir) base_dir = os.path.dirname(project_dir) ext_backend_base_dirs = self._ext_backend_paths() @@ -134,7 +137,7 @@ class AdminScriptTestCase(unittest.TestCase): return out, err def run_django_admin(self, args, settings_file=None): - bin_dir = os.path.abspath(os.path.dirname(bin.__file__)) + bin_dir = os.path.abspath(os.path.dirname(upath(bin.__file__))) return self.run_test(os.path.join(bin_dir, 'django-admin.py'), args, settings_file) def run_manage(self, args, settings_file=None): @@ -144,7 +147,7 @@ class AdminScriptTestCase(unittest.TestCase): except OSError: pass - conf_dir = os.path.dirname(conf.__file__) + conf_dir = os.path.dirname(upath(conf.__file__)) template_manage_py = os.path.join(conf_dir, 'project_template', 'manage.py') test_manage_py = os.path.join(test_dir, 'manage.py') @@ -166,10 +169,12 @@ class AdminScriptTestCase(unittest.TestCase): def assertOutput(self, stream, msg): "Utility assertion: assert that the given message exists in the output" + stream = force_text(stream) self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream)) def assertNotInOutput(self, stream, msg): "Utility assertion: assert that the given message doesn't exist in the output" + stream = force_text(stream) self.assertFalse(msg in stream, "'%s' matches actual output text '%s'" % (msg, stream)) ########################################################################## @@ -1553,7 +1558,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase): self.assertNoOutput(err) test_manage_py = os.path.join(testproject_dir, 'manage.py') with open(test_manage_py, 'r') as fp: - content = fp.read() + content = force_text(fp.read()) self.assertIn("project_name = 'another_project'", content) self.assertIn("project_directory = '%s'" % testproject_dir, content) -- cgit v1.3