1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-23 22:23:47 +00:00

PY3 fix tests pipelines files

This commit is contained in:
nyov 2015-07-29 17:38:13 +00:00 committed by Mikhail Korobov
parent 6e762ce25c
commit 991197003b
2 changed files with 4 additions and 2 deletions

View File

@ -26,6 +26,7 @@ from scrapy.exceptions import NotConfigured, IgnoreRequest
from scrapy.http import Request
from scrapy.utils.misc import md5sum
from scrapy.utils.log import failure_to_exc_info
from scrapy.utils.python import to_bytes
logger = 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 deprecation
media_ext = os.path.splitext(url)[1] # change to request.url after deprecation
return 'full/%s%s' % (media_guid, media_ext)

View File

@ -12,6 +12,7 @@ from scrapy.pipelines.files import FilesPipeline, FSFilesStore
from scrapy.item import Item, Field
from scrapy.http import Request, Response
from scrapy.settings import Settings
from scrapy.utils.python import to_bytes
from 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)