Commit f0b8f72d by Thomas Parslow Committed by Timothée Peignier

Mime types should not be unicode strings

parent 3f5ad202
...@@ -63,11 +63,11 @@ DEFAULTS = { ...@@ -63,11 +63,11 @@ DEFAULTS = {
'PIPELINE_LESS_ARGUMENTS': '', 'PIPELINE_LESS_ARGUMENTS': '',
'PIPELINE_MIMETYPES': ( 'PIPELINE_MIMETYPES': (
('text/coffeescript', '.coffee'), (b'text/coffeescript', '.coffee'),
('text/less', '.less'), (b'text/less', '.less'),
('text/javascript', '.js'), (b'application/javascript', '.js'),
('text/x-sass', '.sass'), (b'text/x-sass', '.sass'),
('text/x-scss', '.scss') (b'text/x-scss', '.scss')
), ),
'PIPELINE_EMBED_MAX_IMAGE_SIZE': 32700, 'PIPELINE_EMBED_MAX_IMAGE_SIZE': 32700,
......
...@@ -36,7 +36,7 @@ def guess_type(path, default=None): ...@@ -36,7 +36,7 @@ def guess_type(path, default=None):
mimetype, _ = mimetypes.guess_type(path) mimetype, _ = mimetypes.guess_type(path)
if not mimetype: if not mimetype:
return default return default
return mimetype return smart_str(mimetype)
def relpath(path, start=posixpath.curdir): def relpath(path, start=posixpath.curdir):
......
...@@ -35,19 +35,19 @@ class JinjaTest(TestCase): ...@@ -35,19 +35,19 @@ class JinjaTest(TestCase):
def test_package_js(self): def test_package_js(self):
template = self.env.from_string(u"""{% compressed_js "scripts" %}""") template = self.env.from_string(u"""{% compressed_js "scripts" %}""")
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', template.render()) self.assertEqual(u'<script type="application/javascript" src="/static/scripts.js" charset="utf-8"></script>', template.render())
def test_package_js_async(self): def test_package_js_async(self):
template = self.env.from_string(u"""{% compressed_js "scripts_async" %}""") template = self.env.from_string(u"""{% compressed_js "scripts_async" %}""")
self.assertEqual(u'<script async type="text/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', template.render()) self.assertEqual(u'<script async type="application/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', template.render())
def test_package_js_defer(self): def test_package_js_defer(self):
template = self.env.from_string(u"""{% compressed_js "scripts_defer" %}""") template = self.env.from_string(u"""{% compressed_js "scripts_defer" %}""")
self.assertEqual(u'<script defer type="text/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', template.render()) self.assertEqual(u'<script defer type="application/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', template.render())
def test_package_js_async_defer(self): def test_package_js_async_defer(self):
template = self.env.from_string(u"""{% compressed_js "scripts_async_defer" %}""") template = self.env.from_string(u"""{% compressed_js "scripts_async_defer" %}""")
self.assertEqual(u'<script async defer type="text/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', template.render()) self.assertEqual(u'<script async defer type="application/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', template.render())
class DjangoTest(TestCase): class DjangoTest(TestCase):
...@@ -64,16 +64,16 @@ class DjangoTest(TestCase): ...@@ -64,16 +64,16 @@ class DjangoTest(TestCase):
def test_compressed_js(self): def test_compressed_js(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts" %}""") rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts" %}""")
self.assertEqual(u'<script type="text/javascript" src="/static/scripts.js" charset="utf-8"></script>', rendered) self.assertEqual(u'<script type="application/javascript" src="/static/scripts.js" charset="utf-8"></script>', rendered)
def test_compressed_js_async(self): def test_compressed_js_async(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async" %}""") rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async" %}""")
self.assertEqual(u'<script async type="text/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', rendered) self.assertEqual(u'<script async type="application/javascript" src="/static/scripts_async.js" charset="utf-8"></script>', rendered)
def test_compressed_js_defer(self): def test_compressed_js_defer(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_defer" %}""") rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_defer" %}""")
self.assertEqual(u'<script defer type="text/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', rendered) self.assertEqual(u'<script defer type="application/javascript" src="/static/scripts_defer.js" charset="utf-8"></script>', rendered)
def test_compressed_js_async_defer(self): def test_compressed_js_async_defer(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async_defer" %}""") rendered = self.render_template(u"""{% load compressed %}{% compressed_js "scripts_async_defer" %}""")
self.assertEqual(u'<script async defer type="text/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', rendered) self.assertEqual(u'<script async defer type="application/javascript" src="/static/scripts_async_defer.js" charset="utf-8"></script>', rendered)
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