Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #18404 -- Added test for AppStaticStorage with non ascii path

(bug was already fixed in #19357)
  • Loading branch information...
commit ca39c0a6becf497880181b3a5ef6db84130f9723 1 parent e07e403
Florian Hahn authored February 24, 2013 timgraham committed July 27, 2013

Showing 1 changed file with 30 additions and 0 deletions. Show diff stats Hide diff stats

  1. 30  tests/staticfiles_tests/tests.py
30  tests/staticfiles_tests/tests.py
@@ -774,3 +774,33 @@ def test_template_tag(self):
774 774
         self.assertStaticRenders("does/not/exist.png",
775 775
                                    "/static/does/not/exist.png")
776 776
         self.assertStaticRenders("testfile.txt", "/static/testfile.txt")
  777
+
  778
+
  779
+class TestAppStaticStorage(TestCase):
  780
+    def setUp(self):
  781
+        # Creates a python module foo_module in a directory with non ascii
  782
+        # characters
  783
+        self.search_path = 'search_path_\xc3\xbc'
  784
+        os.mkdir(self.search_path)
  785
+        module_path = os.path.join(self.search_path, 'foo_module')
  786
+        os.mkdir(module_path)
  787
+        open(os.path.join(module_path, '__init__.py'), 'w')
  788
+        sys.path.append(os.path.abspath(self.search_path))
  789
+
  790
+    def tearDown(self):
  791
+        sys.path.remove(os.path.abspath(self.search_path))
  792
+        shutil.rmtree(self.search_path)
  793
+
  794
+    def test_app_with_non_ascii_characters_in_path(self):
  795
+        """
  796
+        Regression test for #18404 - Tests AppStaticStorage with a module that
  797
+        has non ascii characters in path and a non utf8 file system encoding
  798
+        """
  799
+        # set file system encoding to a non unicode encoding
  800
+        old_enc_func = sys.getfilesystemencoding
  801
+        sys.getfilesystemencoding = lambda: 'ISO-8859-1'
  802
+        try:
  803
+            st = storage.AppStaticStorage('foo_module')
  804
+            st.path('bar')
  805
+        finally:
  806
+            sys.getfilesystemencoding = old_enc_func

0 notes on commit ca39c0a

Please sign in to comment.
Something went wrong with that request. Please try again.