Scrapy, a fast high-level web crawling & scraping framework for Python.
PY3 fix tests pipelines images
nyov34eced0ee822
diff --git a/scrapy/pipelines/images.py b/scrapy/pipelines/images.pyindex 8b3bc2222..ff73b44b7 100644--- a/scrapy/pipelines/images.py+++ b/scrapy/pipelines/images.py@@ -15,6 +15,7 @@ except ImportError:from PIL import Imagefrom scrapy.utils.misc import md5sum+from scrapy.utils.python import to_bytesfrom scrapy.http import Requestfrom scrapy.exceptions import DropItem#TODO: from scrapy.pipelines.media import MediaPipeline@@ -138,7 +139,7 @@ class ImagesPipeline(FilesPipeline):return self.image_key(url)## end of deprecation warning block- image_guid = hashlib.sha1(url).hexdigest() # change to request.url after deprecation+ image_guid = hashlib.sha1(to_bytes(url)).hexdigest() # change to request.url after deprecationreturn 'full/%s.jpg' % (image_guid)def thumb_path(self, request, thumb_id, response=None, info=None):@@ -163,7 +164,7 @@ class ImagesPipeline(FilesPipeline):return self.thumb_key(url, thumb_id)## end of deprecation warning block- thumb_guid = hashlib.sha1(url).hexdigest() # change to request.url after deprecation+ thumb_guid = hashlib.sha1(to_bytes(url)).hexdigest() # change to request.url after deprecationreturn 'thumbs/%s/%s.jpg' % (thumb_id, thumb_guid)# deprecateddiff --git a/tests/test_pipeline_images.py b/tests/test_pipeline_images.pyindex 04cec4b8e..f52fb4d3d 100644--- a/tests/test_pipeline_images.py+++ b/tests/test_pipeline_images.py@@ -10,6 +10,7 @@ from scrapy.item import Item, Fieldfrom scrapy.http import Request, Responsefrom scrapy.settings import Settingsfrom scrapy.pipelines.images import ImagesPipeline+from scrapy.utils.python import to_bytesskip = Falsetry:@@ -100,11 +101,11 @@ class DeprecatedImagesPipeline(ImagesPipeline):return self.image_key(url)def image_key(self, url):- image_guid = hashlib.sha1(url).hexdigest()+ image_guid = hashlib.sha1(to_bytes(url)).hexdigest()return 'empty/%s.jpg' % (image_guid)def thumb_key(self, url, thumb_id):- thumb_guid = hashlib.sha1(url).hexdigest()+ thumb_guid = hashlib.sha1(to_bytes(url)).hexdigest()return 'thumbsup/%s/%s.jpg' % (thumb_id, thumb_guid)