summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2013-02-24 00:01:45 +0100
committerTim Graham <timograham@gmail.com>2013-07-27 20:18:32 -0400
commitca39c0a6becf497880181b3a5ef6db84130f9723 (patch)
treea69ee2a4610e310b79172abe6936b9516b830792
parente07e4030b9170d522a9670a80c4fd40acff369cb (diff)
Fixed #18404 -- Added test for AppStaticStorage with non ascii path
(bug was already fixed in #19357)
-rw-r--r--tests/staticfiles_tests/tests.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py
index 912dcffe83..bb33c40423 100644
--- a/tests/staticfiles_tests/tests.py
+++ b/tests/staticfiles_tests/tests.py
@@ -774,3 +774,33 @@ class TestTemplateTag(StaticFilesTestCase):
self.assertStaticRenders("does/not/exist.png",
"/static/does/not/exist.png")
self.assertStaticRenders("testfile.txt", "/static/testfile.txt")
+
+
+class TestAppStaticStorage(TestCase):
+ def setUp(self):
+ # Creates a python module foo_module in a directory with non ascii
+ # characters
+ self.search_path = 'search_path_\xc3\xbc'
+ os.mkdir(self.search_path)
+ module_path = os.path.join(self.search_path, 'foo_module')
+ os.mkdir(module_path)
+ open(os.path.join(module_path, '__init__.py'), 'w')
+ sys.path.append(os.path.abspath(self.search_path))
+
+ def tearDown(self):
+ sys.path.remove(os.path.abspath(self.search_path))
+ shutil.rmtree(self.search_path)
+
+ def test_app_with_non_ascii_characters_in_path(self):
+ """
+ Regression test for #18404 - Tests AppStaticStorage with a module that
+ has non ascii characters in path and a non utf8 file system encoding
+ """
+ # set file system encoding to a non unicode encoding
+ old_enc_func = sys.getfilesystemencoding
+ sys.getfilesystemencoding = lambda: 'ISO-8859-1'
+ try:
+ st = storage.AppStaticStorage('foo_module')
+ st.path('bar')
+ finally:
+ sys.getfilesystemencoding = old_enc_func