[py3] Fixed staticfiles tests

This commit is contained in:
Claude Paroz 2012-08-14 17:24:31 +02:00
parent 9cb80356fc
commit 7d48e077b5
3 changed files with 7 additions and 7 deletions

View File

@ -51,8 +51,8 @@ class CachedFilesMixin(object):
default_template = """url("%s")""" default_template = """url("%s")"""
patterns = ( patterns = (
("*.css", ( ("*.css", (
br"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""", r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""",
(br"""(@import\s*["']\s*(.*?)["'])""", """@import url("%s")"""), (r"""(@import\s*["']\s*(.*?)["'])""", """@import url("%s")"""),
)), )),
) )

View File

@ -225,7 +225,7 @@ def filepath_to_uri(path):
return path return path
# I know about `os.sep` and `os.altsep` but I want to leave # I know about `os.sep` and `os.altsep` but I want to leave
# some flexibility for hardcoding separators. # some flexibility for hardcoding separators.
return quote(smart_bytes(path).replace("\\", "/"), safe=b"/~!*()'") return quote(smart_bytes(path.replace("\\", "/")), safe=b"/~!*()'")
# The encoding of the default system locale but falls back to the # The encoding of the default system locale but falls back to the
# given fallback encoding if the encoding is unsupported by python or could # given fallback encoding if the encoding is unsupported by python or could

View File

@ -527,11 +527,11 @@ class TestCollectionCachedStorage(BaseCollectionTestCase,
""" """
Handle cache key creation correctly, see #17861. Handle cache key creation correctly, see #17861.
""" """
name = b"/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/" + chr(22) + chr(180) name = "/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/" + "\x16" + "\xb4"
cache_key = storage.staticfiles_storage.cache_key(name) cache_key = storage.staticfiles_storage.cache_key(name)
cache_validator = BaseCache({}) cache_validator = BaseCache({})
cache_validator.validate_key(cache_key) cache_validator.validate_key(cache_key)
self.assertEqual(cache_key, 'staticfiles:e95bbc36387084582df2a70750d7b351') self.assertEqual(cache_key, 'staticfiles:821ea71ef36f95b3922a77f7364670e7')
# we set DEBUG to False here since the template tag wouldn't work otherwise # we set DEBUG to False here since the template tag wouldn't work otherwise
@ -569,8 +569,8 @@ class TestCollectionSimpleCachedStorage(BaseCollectionTestCase,
self.assertEqual(relpath, "cached/styles.deploy12345.css") self.assertEqual(relpath, "cached/styles.deploy12345.css")
with storage.staticfiles_storage.open(relpath) as relfile: with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read() content = relfile.read()
self.assertNotIn("cached/other.css", content) self.assertNotIn(b"cached/other.css", content)
self.assertIn("other.deploy12345.css", content) self.assertIn(b"other.deploy12345.css", content)
if sys.platform != 'win32': if sys.platform != 'win32':