Skip to content

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

py3: body to bytes in tests, unskip test file

Konstantin Lopuhin94ab7bee6c56
diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txt
index 57e80f590..0da1b6089 100644
--- a/tests/py3-ignores.txt
+++ b/tests/py3-ignores.txt
@@ -7,7 +7,6 @@ tests/test_crawl.py
tests/test_downloadermiddleware_httpcache.py
tests/test_downloadermiddleware_httpcompression.py
tests/test_downloadermiddleware_httpproxy.py
-tests/test_downloadermiddleware.py
tests/test_downloadermiddleware_retry.py
tests/test_engine.py
tests/test_mail.py
diff --git a/tests/test_downloadermiddleware.py b/tests/test_downloadermiddleware.py
index 13f35b92a..fb51392b2 100644
--- a/tests/test_downloadermiddleware.py
+++ b/tests/test_downloadermiddleware.py
@@ -5,6 +5,7 @@ from scrapy.http import Request, Response
from scrapy.spiders import Spider
from scrapy.core.downloader.middleware import DownloaderMiddlewareManager
from scrapy.utils.test import get_crawler
+from scrapy.utils.python import to_bytes
from tests import mock
@@ -68,7 +69,7 @@ class DefaultsTest(ManagerTestCase):
"""
req = Request('http://example.com')
- body = '<p>You are being redirected</p>'
+ body = b'<p>You are being redirected</p>'
resp = Response(req.url, status=302, body=body, headers={
'Content-Length': str(len(body)),
'Content-Type': 'text/html',
@@ -78,12 +79,12 @@ class DefaultsTest(ManagerTestCase):
ret = self._download(request=req, response=resp)
self.assertTrue(isinstance(ret, Request),
"Not redirected: {0!r}".format(ret))
- self.assertEqual(ret.url, resp.headers['Location'],
+ self.assertEqual(to_bytes(ret.url), resp.headers['Location'],
"Not redirected to location header")
def test_200_and_invalid_gzipped_body_must_fail(self):
req = Request('http://example.com')
- body = '<p>You are being redirected</p>'
+ body = b'<p>You are being redirected</p>'
resp = Response(req.url, status=200, body=body, headers={
'Content-Length': str(len(body)),
'Content-Type': 'text/html',