Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

PY3 fix test downloadermiddleware decompression

nyove044bfa60f07
diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.py
index 7c017feef..c212f5706 100644
--- a/scrapy/responsetypes.py
+++ b/scrapy/responsetypes.py
@@ -92,9 +92,9 @@ class ResponseTypes(object):
chunk = body[:5000]
if isbinarytext(chunk):
return self.from_mimetype('application/octet-stream')
- elif "<html>" in chunk.lower():
+ elif b"<html>" in chunk.lower():
return self.from_mimetype('text/html')
- elif "<?xml" in chunk.lower():
+ elif b"<?xml" in chunk.lower():
return self.from_mimetype('text/xml')
else:
return self.from_mimetype('text')
diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txt
index 96b07ae28..84bd01c0e 100644
--- a/tests/py3-ignores.txt
+++ b/tests/py3-ignores.txt
@@ -12,7 +12,6 @@ tests/test_crawler.py
tests/test_downloader_handlers.py
tests/test_downloadermiddleware_ajaxcrawlable.py
tests/test_downloadermiddleware_cookies.py
-tests/test_downloadermiddleware_decompression.py
tests/test_downloadermiddleware_defaultheaders.py
tests/test_downloadermiddleware_downloadtimeout.py
tests/test_downloadermiddleware_httpauth.py
diff --git a/tests/test_downloadermiddleware_decompression.py b/tests/test_downloadermiddleware_decompression.py
index 9143611fc..77b35a8c3 100644
--- a/tests/test_downloadermiddleware_decompression.py
+++ b/tests/test_downloadermiddleware_decompression.py
@@ -39,7 +39,7 @@ class DecompressionMiddlewareTest(TestCase):
assert_samelines(self, new.body, rsp.body)
def test_empty_response(self):
- rsp = Response(url='http://test.com', body='')
+ rsp = Response(url='http://test.com', body=b'')
new = self.mw.process_response(None, rsp, self.spider)
assert new is rsp
assert not rsp.body
diff --git a/tests/test_responsetypes.py b/tests/test_responsetypes.py
index b4083403a..1d78d0976 100644
--- a/tests/test_responsetypes.py
+++ b/tests/test_responsetypes.py
@@ -51,7 +51,7 @@ class ResponseTypesTest(unittest.TestCase):
for source, cls in mappings:
retcls = responsetypes.from_body(source)
assert retcls is cls, "%s ==> %s != %s" % (source, retcls, cls)
-
+
def test_from_headers(self):
mappings = [
({'Content-Type': ['text/html; charset=utf-8']}, HtmlResponse),