From d2accf2e39dba6d6d48eeb9683081067fa46a352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Tue, 21 Jun 2022 12:02:56 +0200 Subject: [PATCH] Fix issues reported by static checks --- scrapy/responsetypes.py | 3 ++- tests/test_responsetypes.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.py index 13f9df52a..1bf21ca81 100644 --- a/scrapy/responsetypes.py +++ b/scrapy/responsetypes.py @@ -32,7 +32,8 @@ _CONTENT_ENCODING_MIME_TYPES = { 'gzip': b'application/gzip', } _MIME_TYPES = MimeTypes() -_MIME_TYPES.readfp(StringIO(get_data('scrapy', 'mime.types').decode())) +_scrapy_mime_data = get_data('scrapy', 'mime.types') or b'' +_MIME_TYPES.readfp(StringIO(_scrapy_mime_data.decode())) def _is_other_text_mime_type(mime_type): diff --git a/tests/test_responsetypes.py b/tests/test_responsetypes.py index ebfe78f1e..075b0ad22 100644 --- a/tests/test_responsetypes.py +++ b/tests/test_responsetypes.py @@ -174,8 +174,8 @@ class ResponseTypesTest(unittest.TestCase): def test_custom_mime_types_loaded(self): """Check that mime.types files shipped with Scrapy are loaded.""" self.assertEqual( - _MIME_TYPES.guess_type('x.scrapytest')[0], - 'x-scrapy/test', + _MIME_TYPES.guess_type('x.scrapytest')[0], + 'x-scrapy/test', )