From 762a549e74c1faaf77d10d5d1190c11abfa8edb2 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 24 Feb 2010 16:09:19 +0100 Subject: [PATCH] Added another test for latin-1 encoded files to be on the safe side. --- compressor/__init__.py | 4 ++-- tests/core/tests.py | 10 ++++++++++ tests/media/js/nonasc-latin1.js | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/media/js/nonasc-latin1.js diff --git a/compressor/__init__.py b/compressor/__init__.py index ef822f1..22e67b0 100644 --- a/compressor/__init__.py +++ b/compressor/__init__.py @@ -83,7 +83,8 @@ class Compressor(object): input = fd.read() if self.filters: input = self.filter(input, 'input', filename=v, elem=elem) - self._hunks.append(unicode(input, elem.get('charset', django_settings.DEFAULT_CHARSET))) + charset = elem.get('charset', django_settings.DEFAULT_CHARSET) + self._hunks.append(unicode(input, charset)) fd.close() return self._hunks @@ -94,7 +95,6 @@ class Compressor(object): return "\n".join([hunk.encode(django_settings.DEFAULT_CHARSET) for hunk in self.hunks]) def filter(self, content, method, **kwargs): - content = content for f in self.filters: filter = getattr(filters.get_class(f)(content, filter_type=self.type), method) try: diff --git a/tests/core/tests.py b/tests/core/tests.py index 2b528eb..9d370bf 100644 --- a/tests/core/tests.py +++ b/tests/core/tests.py @@ -213,6 +213,16 @@ class TemplatetagTestCase(TestCase): out = u'' self.assertEqual(out, render(template, context)) + def test_nonascii_latin1_js_tag(self): + template = u"""{% load compress %}{% compress js %} + + + {% endcompress %} + """ + context = { 'MEDIA_URL': settings.MEDIA_URL } + out = u'' + self.assertEqual(out, render(template, context)) + class TestStorage(CompressorFileStorage): """ Test compressor storage that gzips storage files diff --git a/tests/media/js/nonasc-latin1.js b/tests/media/js/nonasc-latin1.js new file mode 100644 index 0000000..109aa20 --- /dev/null +++ b/tests/media/js/nonasc-latin1.js @@ -0,0 +1 @@ +var test_value = "Überstríng";