diff --git a/compressor/base.py b/compressor/base.py
index b13d3c9..8f24b0d 100644
--- a/compressor/base.py
+++ b/compressor/base.py
@@ -111,9 +111,10 @@ class Compressor(object):
command = self.all_mimetypes.get(mimetype)
if command is None:
if mimetype not in ("text/css", "text/javascript"):
- raise CompressorError(
- "Couldn't find any configured precompiler "
- "for mimetype '%s'." % mimetype)
+ error = ("Couldn't find any precompiler in "
+ "COMPRESS_PRECOMPILERS setting for "
+ "mimetype '%s'." % mimetype)
+ raise CompressorError(error)
else:
content = CompilerFilter(content, filter_type=self.type,
command=command).output(**kwargs)
@@ -178,7 +179,7 @@ class Compressor(object):
The output method that saves the content to a file and renders
the appropriate template with the file's URL.
"""
- new_filepath = self.filepath(content)
+ new_filepath = self.filepath(self.content)
if not self.storage.exists(new_filepath):
self.storage.save(new_filepath, ContentFile(content))
url = self.storage.url(new_filepath)
diff --git a/compressor/cache.py b/compressor/cache.py
index f832b4d..e53f4b8 100644
--- a/compressor/cache.py
+++ b/compressor/cache.py
@@ -9,7 +9,7 @@ from compressor.conf import settings
def get_hexdigest(plaintext, length=None):
- digest = sha_constructor(plaintext).hexdigest()
+ digest = sha_constructor(smart_str(plaintext)).hexdigest()
if length:
return digest[:length]
return digest
diff --git a/compressor/css.py b/compressor/css.py
index 90f5c0f..9f4ae58 100644
--- a/compressor/css.py
+++ b/compressor/css.py
@@ -37,7 +37,7 @@ class CssCompressor(Compressor):
if self.media_nodes and self.media_nodes[-1][0] == media:
self.media_nodes[-1][1].split_content.append(data)
else:
- node = CssCompressor()
+ node = CssCompressor(str(elem))
node.split_content.append(data)
self.media_nodes.append((media, node))
return self.split_content
diff --git a/compressor/tests/tests.py b/compressor/tests/tests.py
index 49d21a9..0f5a580 100644
--- a/compressor/tests/tests.py
+++ b/compressor/tests/tests.py
@@ -72,10 +72,10 @@ class CompressorTestCase(TestCase):
self.assert_(is_cachekey.match(self.css_node.cachekey), "cachekey is returning something that doesn't look like r'django_compressor\.%s\.\w{12}'" % host_name)
def test_css_hash(self):
- self.assertEqual('f7c661b7a124', self.css_node.hash(self.css_node.concat))
+ self.assertEqual('666f3aa8eacd', self.css_node.hash(self.css))
def test_css_return_if_on(self):
- output = u''
+ output = u''
self.assertEqual(output, self.css_node.output().strip())
def test_js_split(self):
@@ -110,20 +110,20 @@ class CompressorTestCase(TestCase):
settings.COMPRESS_PRECOMPILERS = precompilers
def test_js_return_if_on(self):
- output = u''
+ output = u''
self.assertEqual(output, self.js_node.output())
def test_custom_output_dir(self):
try:
old_output_dir = settings.COMPRESS_OUTPUT_DIR
settings.COMPRESS_OUTPUT_DIR = 'custom'
- output = u''
+ output = u''
self.assertEqual(output, JsCompressor(self.js).output())
settings.COMPRESS_OUTPUT_DIR = ''
- output = u''
+ output = u''
self.assertEqual(output, JsCompressor(self.js).output())
settings.COMPRESS_OUTPUT_DIR = '/custom/nested/'
- output = u''
+ output = u''
self.assertEqual(output, JsCompressor(self.js).output())
finally:
settings.COMPRESS_OUTPUT_DIR = old_output_dir
@@ -290,7 +290,7 @@ class TemplatetagTestCase(TestCase):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u''
+ out = u''
self.assertEqual(out, render(template, context))
def test_nonascii_css_tag(self):
@@ -300,7 +300,7 @@ class TemplatetagTestCase(TestCase):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = ''
+ out = ''
self.assertEqual(out, render(template, context))
def test_js_tag(self):
@@ -310,7 +310,7 @@ class TemplatetagTestCase(TestCase):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u''
+ out = u''
self.assertEqual(out, render(template, context))
def test_nonascii_js_tag(self):
@@ -320,7 +320,7 @@ class TemplatetagTestCase(TestCase):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u''
+ out = u''
self.assertEqual(out, render(template, context))
def test_nonascii_latin1_js_tag(self):
@@ -330,7 +330,7 @@ class TemplatetagTestCase(TestCase):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u''
+ out = u''
self.assertEqual(out, render(template, context))
def test_compress_tag_with_illegal_arguments(self):
@@ -357,7 +357,7 @@ class StorageTestCase(TestCase):
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.COMPRESS_URL }
- out = u''
+ out = u''
self.assertEqual(out, render(template, context))
@@ -377,6 +377,7 @@ class CacheBackendTestCase(CompressorTestCase):
class OfflineGenerationTestCase(TestCase):
"""Uses templates/test_compressor_offline.html"""
+ maxDiff = None
def setUp(self):
self._old_compress = settings.COMPRESS_ENABLED
@@ -389,8 +390,8 @@ class OfflineGenerationTestCase(TestCase):
count, result = CompressCommand().compress()
self.assertEqual(2, count)
self.assertEqual([
- u'\n',
- u'',
+ u'\n',
+ u'',
], result)
def test_offline_with_context(self):
@@ -401,7 +402,7 @@ class OfflineGenerationTestCase(TestCase):
count, result = CompressCommand().compress()
self.assertEqual(2, count)
self.assertEqual([
- u'\n',
- u'',
+ u'\n',
+ u'',
], result)
settings.COMPRESS_OFFLINE_CONTEXT = self._old_offline_context