mirror of https://github.com/scrapy/scrapy.git
PY3 fix test downloadermiddleware decompression
This commit is contained in:
parent
ec8afbc060
commit
e044bfa60f
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in New Issue