mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #19357 -- Allow non-ASCII chars in filesystem paths
Thanks kujiu for the report and Aymeric Augustin for the review.
This commit is contained in:
parent
53b879f045
commit
c91667338a
56 changed files with 228 additions and 147 deletions
|
@ -15,14 +15,14 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import empty
|
||||
from django.utils._os import rmtree_errorhandler
|
||||
from django.utils._os import rmtree_errorhandler, upath
|
||||
from django.utils import six
|
||||
|
||||
from django.contrib.staticfiles import finders, storage
|
||||
|
||||
TEST_ROOT = os.path.dirname(__file__)
|
||||
TEST_ROOT = os.path.dirname(upath(__file__))
|
||||
TEST_SETTINGS = {
|
||||
'DEBUG': True,
|
||||
'MEDIA_URL': '/media/',
|
||||
|
@ -77,7 +77,7 @@ class BaseStaticFilesTestCase(object):
|
|||
os.unlink(self._backup_filepath)
|
||||
|
||||
def assertFileContains(self, filepath, text):
|
||||
self.assertIn(text, self._get_file(smart_text(filepath)),
|
||||
self.assertIn(text, self._get_file(force_text(filepath)),
|
||||
"'%s' not in '%s'" % (text, filepath))
|
||||
|
||||
def assertFileNotFound(self, filepath):
|
||||
|
@ -195,7 +195,7 @@ class TestFindStatic(CollectionTestCase, TestDefaults):
|
|||
call_command('findstatic', filepath, all=False, verbosity=0, stdout=out)
|
||||
out.seek(0)
|
||||
lines = [l.strip() for l in out.readlines()]
|
||||
with codecs.open(smart_text(lines[1].strip()), "r", "utf-8") as f:
|
||||
with codecs.open(force_text(lines[1].strip()), "r", "utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
def test_all_files(self):
|
||||
|
@ -207,8 +207,8 @@ class TestFindStatic(CollectionTestCase, TestDefaults):
|
|||
out.seek(0)
|
||||
lines = [l.strip() for l in out.readlines()]
|
||||
self.assertEqual(len(lines), 3) # three because there is also the "Found <file> here" line
|
||||
self.assertIn('project', lines[1])
|
||||
self.assertIn('apps', lines[2])
|
||||
self.assertIn('project', force_text(lines[1]))
|
||||
self.assertIn('apps', force_text(lines[2]))
|
||||
|
||||
|
||||
class TestCollection(CollectionTestCase, TestDefaults):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue