diff --git a/compressor/tests/static/img/add with spaces.png b/compressor/tests/static/img/add with spaces.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/compressor/tests/static/img/add with spaces.png differ diff --git a/compressor/tests/test_filters.py b/compressor/tests/test_filters.py index 626ec24..84b1862 100644 --- a/compressor/tests/test_filters.py +++ b/compressor/tests/test_filters.py @@ -339,6 +339,21 @@ p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%(compress_u filter = CssAbsoluteFilter(content) 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/') class CssAbsolutizingTestCaseWithDifferentURL(CssAbsolutizingTestCase): diff --git a/compressor/tests/test_mtime_cache.py b/compressor/tests/test_mtime_cache.py index fd0006c..69dc7c7 100644 --- a/compressor/tests/test_mtime_cache.py +++ b/compressor/tests/test_mtime_cache.py @@ -24,8 +24,8 @@ class TestMtimeCacheCommand(TestCase): call_command( 'mtime_cache', '--add', *self.default_ignore(), stdout=out) output = out.getvalue() - self.assertIn('Deleted mtimes of 19 files from the cache.', output) - self.assertIn('Added mtimes of 19 files to cache.', output) + self.assertIn('Deleted mtimes of 20 files from the cache.', output) + self.assertIn('Added mtimes of 20 files to cache.', output) def test_handle_clean(self): out = StringIO() @@ -33,5 +33,5 @@ class TestMtimeCacheCommand(TestCase): call_command( 'mtime_cache', '--clean', *self.default_ignore(), stdout=out) output = out.getvalue() - self.assertIn('Deleted mtimes of 19 files from the cache.', output) - self.assertNotIn('Added mtimes of 19 files to cache.', output) + self.assertIn('Deleted mtimes of 20 files from the cache.', output) + self.assertNotIn('Added mtimes of 20 files to cache.', output)