Skip to content

Commit 9911970

Browse files
nyovkmike
authored andcommitted
PY3 fix tests pipelines files
1 parent 6e762ce commit 9911970

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

scrapy/pipelines/files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from scrapy.http import Request
2727
from scrapy.utils.misc import md5sum
2828
from scrapy.utils.log import failure_to_exc_info
29+
from scrapy.utils.python import to_bytes
2930

3031
logger = logging.getLogger(__name__)
3132

@@ -330,7 +331,7 @@ def _warn():
330331
return self.file_key(url)
331332
## end of deprecation warning block
332333

333-
media_guid = hashlib.sha1(url).hexdigest() # change to request.url after deprecation
334+
media_guid = hashlib.sha1(to_bytes(url)).hexdigest() # change to request.url after deprecation
334335
media_ext = os.path.splitext(url)[1] # change to request.url after deprecation
335336
return 'full/%s%s' % (media_guid, media_ext)
336337

tests/test_pipeline_files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from scrapy.item import Item, Field
1313
from scrapy.http import Request, Response
1414
from scrapy.settings import Settings
15+
from scrapy.utils.python import to_bytes
1516

1617
from tests import mock
1718

@@ -103,7 +104,7 @@ def test_file_expired(self):
103104

104105
class DeprecatedFilesPipeline(FilesPipeline):
105106
def file_key(self, url):
106-
media_guid = hashlib.sha1(url).hexdigest()
107+
media_guid = hashlib.sha1(to_bytes(url)).hexdigest()
107108
media_ext = os.path.splitext(url)[1]
108109
return 'empty/%s%s' % (media_guid, media_ext)
109110

0 commit comments

Comments
 (0)