Commit c8ed240d by Timothée Peignier

test css url rewrite

parent 5072bbeb
......@@ -23,7 +23,7 @@ class Compiler(object):
try:
compiled_content = compiler.compile_file(content)
self.save_file(new_path, compiled_content)
except CompilerError, e:
except CompilerError:
if not os.path.exists(new_path):
raise
paths[index] = new_path
......
.relative-url {
background-image: url(../images/sprite-buttons.png);
}
.absolute-url {
background-image: url(http://localhost/images/sprite-buttons.png);
}
.no-protocol-url {
background-image: url(//images/sprite-buttons.png);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ import os
from django.test import TestCase
from compress.conf import settings
from compress.compressors import Compressor
from compress.packager import Packager
......@@ -28,7 +29,27 @@ class VersioningTest(TestCase):
class CompressorTest(TestCase):
pass
def setUp(self):
self.old_compress_url = settings.COMPRESS_URL
settings.COMPRESS_URL = 'http://localhost/static/'
def test_url_rewrite(self):
compressor = Compressor()
output = compressor.concatenate_and_rewrite([
os.path.join(settings.COMPRESS_ROOT, 'css/urls.css'),
])
self.assertEquals(""".relative-url {
background-image: url(http://localhost/static/images/sprite-buttons.png);
}
.absolute-url {
background-image: url(http://localhost/images/sprite-buttons.png);
}
.no-protocol-url {
background-image: url(//images/sprite-buttons.png);
}""", output)
def tearDown(self):
settings.COMPRESS_URL = self.old_compress_url
class CompilerTest(TestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment