Test whether the CssAbsoluteFilter correctly handles spaces in urls, ref #736
This commit is contained in:
BIN
compressor/tests/static/img/add with spaces.png
Normal file
BIN
compressor/tests/static/img/add with spaces.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 733 B |
@@ -339,6 +339,21 @@ p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%(compress_u
|
|||||||
filter = CssAbsoluteFilter(content)
|
filter = CssAbsoluteFilter(content)
|
||||||
self.assertEqual(path, filter.guess_filename(url))
|
self.assertEqual(path, filter.guess_filename(url))
|
||||||
|
|
||||||
|
def test_filenames_with_space(self):
|
||||||
|
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
|
||||||
|
imagefilename = os.path.join(settings.COMPRESS_ROOT, 'img/add with spaces.png')
|
||||||
|
|
||||||
|
template = "p { background: url('%(url)simg/add with spaces.png%(query)s%(hash)s%(frag)s') }"
|
||||||
|
|
||||||
|
content = template % blankdict(url='../../')
|
||||||
|
params = blankdict({
|
||||||
|
'url': settings.COMPRESS_URL,
|
||||||
|
'hash': '?' + self.hashing_func(imagefilename),
|
||||||
|
})
|
||||||
|
output = template % params
|
||||||
|
filter = CssAbsoluteFilter(content)
|
||||||
|
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
|
||||||
|
|
||||||
|
|
||||||
@override_settings(COMPRESS_URL='http://static.example.com/')
|
@override_settings(COMPRESS_URL='http://static.example.com/')
|
||||||
class CssAbsolutizingTestCaseWithDifferentURL(CssAbsolutizingTestCase):
|
class CssAbsolutizingTestCaseWithDifferentURL(CssAbsolutizingTestCase):
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ class TestMtimeCacheCommand(TestCase):
|
|||||||
call_command(
|
call_command(
|
||||||
'mtime_cache', '--add', *self.default_ignore(), stdout=out)
|
'mtime_cache', '--add', *self.default_ignore(), stdout=out)
|
||||||
output = out.getvalue()
|
output = out.getvalue()
|
||||||
self.assertIn('Deleted mtimes of 19 files from the cache.', output)
|
self.assertIn('Deleted mtimes of 20 files from the cache.', output)
|
||||||
self.assertIn('Added mtimes of 19 files to cache.', output)
|
self.assertIn('Added mtimes of 20 files to cache.', output)
|
||||||
|
|
||||||
def test_handle_clean(self):
|
def test_handle_clean(self):
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
@@ -33,5 +33,5 @@ class TestMtimeCacheCommand(TestCase):
|
|||||||
call_command(
|
call_command(
|
||||||
'mtime_cache', '--clean', *self.default_ignore(), stdout=out)
|
'mtime_cache', '--clean', *self.default_ignore(), stdout=out)
|
||||||
output = out.getvalue()
|
output = out.getvalue()
|
||||||
self.assertIn('Deleted mtimes of 19 files from the cache.', output)
|
self.assertIn('Deleted mtimes of 20 files from the cache.', output)
|
||||||
self.assertNotIn('Added mtimes of 19 files to cache.', output)
|
self.assertNotIn('Added mtimes of 20 files to cache.', output)
|
||||||
|
|||||||
Reference in New Issue
Block a user