From 8fc4f8634ca711b769ed7806e3acd73cdb668c1e Mon Sep 17 00:00:00 2001 From: Johannes Linke Date: Sun, 30 Oct 2016 18:13:59 +0100 Subject: [PATCH] Test whether the CssAbsoluteFilter correctly handles spaces in urls, ref #736 --- compressor/tests/static/img/add with spaces.png | Bin 0 -> 733 bytes compressor/tests/test_filters.py | 15 +++++++++++++++ compressor/tests/test_mtime_cache.py | 8 ++++---- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 compressor/tests/static/img/add with spaces.png 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 0000000000000000000000000000000000000000..6332fefea4be19eeadf211b0b202b272e8564898 GIT binary patch literal 733 zcmV<30wVp1P)9VHk(~TedF+gQSL8D5xnVSSWAVY>J9b+m>@{iq7_KE}go~11+5s4;8hc+i0Xa zI1j@EX5!S+Me6HNqKzU5YQwL;-W5$p%ZMKMeR<%zp69-~?<4?8|C8S?bklXr4v&Ov zb&06v2|-x?qB`90yn>Qi%Sh2^G4n)$ZdyvTPf9}1)_buUT7>`e2G&2VU@~Bb(o+Mz zi4)>IxlSY${Dj4k={-9RzU^W5g9|2V5RZ2ZulL9s2xQbZ@r6eP9Ra5u(s|C0Nj#&4>wTSkb?%#=9?@ z^oxDy-O@tyN{L@by(WWvQ3%CyEu8x{+#Jb4-h&K9Owi)2pgg+heWDyked|3R$$kL@A z#sp1v-r+=G4B8D6DqsDH0@7OztA7aT9qc1Py{()w`m``?Y0&gi2=ROcc-9+nU^I6< zT=e_Y=vSnG@?3Ue{BW5ONFttcE!R-R_W4O01|0-|K-YNXLo2`4Qv z`r1LxR6#yf3FB%T95gJnaKKivA~Z}S9A(ZxEDK}O3T04USJ P00000NkvXXu0mjf^IS-S literal 0 HcmV?d00001 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)