Merge pull request #312 from anttihirvonen/precompiler_unicode_output_fix
Fixed CompilerFilter to always output Unicode strings
This commit is contained in:
@@ -5,6 +5,7 @@ import subprocess
|
|||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.files.temp import NamedTemporaryFile
|
from django.core.files.temp import NamedTemporaryFile
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
|
from django.utils.encoding import smart_unicode
|
||||||
|
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.exceptions import FilterError
|
from compressor.exceptions import FilterError
|
||||||
@@ -140,4 +141,5 @@ class CompilerFilter(FilterBase):
|
|||||||
if self.outfile is not None:
|
if self.outfile is not None:
|
||||||
filtered = self.outfile.read()
|
filtered = self.outfile.read()
|
||||||
self.outfile.close()
|
self.outfile.close()
|
||||||
return filtered
|
|
||||||
|
return smart_unicode(filtered)
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ class PrecompilerTestCase(TestCase):
|
|||||||
compiler = CompilerFilter(content=self.content, filename=self.filename, command=command)
|
compiler = CompilerFilter(content=self.content, filename=self.filename, command=command)
|
||||||
self.assertEqual(u"body { color:#990; }%s" % os.linesep, compiler.input())
|
self.assertEqual(u"body { color:#990; }%s" % os.linesep, compiler.input())
|
||||||
|
|
||||||
|
def test_precompiler_output_unicode(self):
|
||||||
|
command = '%s %s' % (sys.executable, self.test_precompiler)
|
||||||
|
compiler = CompilerFilter(content=self.content, filename=self.filename, command=command)
|
||||||
|
self.assertEqual(type(compiler.input()), unicode)
|
||||||
|
|
||||||
|
|
||||||
class CssMinTestCase(TestCase):
|
class CssMinTestCase(TestCase):
|
||||||
def test_cssmin_filter(self):
|
def test_cssmin_filter(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user