Scrapy, a fast high-level web crawling & scraping framework for Python.
PY3 fix tests pipelines files
nyov991197003bdf
diff --git a/scrapy/pipelines/files.py b/scrapy/pipelines/files.pyindex 308d2f3c1..a85aad4e7 100644--- a/scrapy/pipelines/files.py+++ b/scrapy/pipelines/files.py@@ -26,6 +26,7 @@ from scrapy.exceptions import NotConfigured, IgnoreRequestfrom scrapy.http import Requestfrom scrapy.utils.misc import md5sumfrom scrapy.utils.log import failure_to_exc_info+from scrapy.utils.python import to_byteslogger = logging.getLogger(__name__)@@ -330,7 +331,7 @@ class FilesPipeline(MediaPipeline):return self.file_key(url)## end of deprecation warning block- media_guid = hashlib.sha1(url).hexdigest() # change to request.url after deprecation+ media_guid = hashlib.sha1(to_bytes(url)).hexdigest() # change to request.url after deprecationmedia_ext = os.path.splitext(url)[1] # change to request.url after deprecationreturn 'full/%s%s' % (media_guid, media_ext)diff --git a/tests/test_pipeline_files.py b/tests/test_pipeline_files.pyindex ac0438eba..c9977f5ca 100644--- a/tests/test_pipeline_files.py+++ b/tests/test_pipeline_files.py@@ -12,6 +12,7 @@ from scrapy.pipelines.files import FilesPipeline, FSFilesStorefrom scrapy.item import Item, Fieldfrom scrapy.http import Request, Responsefrom scrapy.settings import Settings+from scrapy.utils.python import to_bytesfrom tests import mock@@ -103,7 +104,7 @@ class FilesPipelineTestCase(unittest.TestCase):class DeprecatedFilesPipeline(FilesPipeline):def file_key(self, url):- media_guid = hashlib.sha1(url).hexdigest()+ media_guid = hashlib.sha1(to_bytes(url)).hexdigest()media_ext = os.path.splitext(url)[1]return 'empty/%s%s' % (media_guid, media_ext)