mirror of https://github.com/scrapy/scrapy.git
fix tests by using a tempfile instead of BytesIO
This commit is contained in:
parent
0786e84a33
commit
1cd9c4d653
|
|
@ -1,9 +1,8 @@
|
|||
import os
|
||||
import hashlib
|
||||
import warnings
|
||||
from tempfile import mkdtemp
|
||||
from tempfile import mkdtemp, TemporaryFile
|
||||
from shutil import rmtree
|
||||
from io import BytesIO
|
||||
|
||||
from twisted.trial import unittest
|
||||
|
||||
|
|
@ -201,7 +200,7 @@ class ImagesPipelineTestCaseFields(unittest.TestCase):
|
|||
|
||||
|
||||
def _create_image(format, *a, **kw):
|
||||
buf = BytesIO()
|
||||
buf = TemporaryFile()
|
||||
Image.new(*a, **kw).save(buf, format)
|
||||
buf.seek(0)
|
||||
return Image.open(buf)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ def _body_or_str(obj, unicode=True):
|
|||
return obj.body_as_unicode()
|
||||
else:
|
||||
return obj.body.decode('utf-8')
|
||||
elif type(obj) is six.text_type:
|
||||
elif isinstance(obj, six.text_type):
|
||||
return obj if unicode else obj.encode('utf-8')
|
||||
else:
|
||||
return obj.decode('utf-8') if unicode else obj
|
||||
|
|
|
|||
Loading…
Reference in New Issue