fix tests by using a tempfile instead of BytesIO

This commit is contained in:
Felix Yan 2014-07-15 21:26:01 +08:00
parent 0786e84a33
commit 1cd9c4d653
2 changed files with 3 additions and 4 deletions

View File

@ -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)

View File

@ -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