Skip to content

Commit

Permalink
Fix unicode/test issues with compass filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
miracle2k committed Aug 21, 2015
1 parent 77cf866 commit 374f268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/webassets/filter/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import tempfile
import shutil
import subprocess
from io import open
from webassets import six

from webassets.exceptions import FilterError
Expand Down Expand Up @@ -233,7 +234,7 @@ def open(self, out, source_path, **kw):

guessed_outputfilename = path.splitext(path.basename(source_path))[0]
guessed_outputfilepath = path.join(tempout, guessed_outputfilename)
output_file = open("%s.css" % guessed_outputfilepath)
output_file = open("%s.css" % guessed_outputfilepath, encoding='utf-8')
if config.get('sourcemap'):
sourcemap_file = open("%s.css.map" % guessed_outputfilepath)
sourcemap_output_filepath = path.join(
Expand All @@ -245,7 +246,7 @@ def open(self, out, source_path, **kw):
sourcemap_output_file = open(sourcemap_output_filepath, 'w')
sourcemap_output_file.write(sourcemap_file.read())
try:
contents = output_file.read().decode('utf-8')
contents = output_file.read()
out.write(contents)
finally:
output_file.close()
Expand Down
6 changes: 5 additions & 1 deletion tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,11 @@ def test_compass_with_unicode(self):

# It's very hard to test this with doctest_match
# And by asserting that it's in the content this test is proven
assert """content: "\xc3\xa1\xc3\xa9";""" in self.get('out.css')
from webassets.six import PY3
if PY3:
assert """content: "áé";""" in self.get('out.css')
else:
assert """content: "\xc3\xa1\xc3\xa9";""" in self.get('out.css')

def test_images_dir(self):
# [bug] Make sure the compass plugin can reference images. It expects
Expand Down

0 comments on commit 374f268

Please sign in to comment.