Use six.StringIO/BytesIO instead of StringIO.StringIO
to keep Python 3.x compatibility, use six.StringIO/BytesIO to replace StringIO.StringIO StringIO works for unicode BytesIO works for bytes Change-Id: I0d1f8a55c3bc41379077b46feb81931779b7ad45 Partial-Bug: #1280100
This commit is contained in:
parent
b7a243b63f
commit
c85286b882
|
@ -20,13 +20,13 @@ import errno
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import StringIO
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import utils
|
from ironic.common import utils
|
||||||
|
@ -233,7 +233,7 @@ class GenericUtilsTestCase(base.TestCase):
|
||||||
|
|
||||||
def test_hash_file(self):
|
def test_hash_file(self):
|
||||||
data = 'Mary had a little lamb, its fleece as white as snow'
|
data = 'Mary had a little lamb, its fleece as white as snow'
|
||||||
flo = StringIO.StringIO(data)
|
flo = six.StringIO(data)
|
||||||
h1 = utils.hash_file(flo)
|
h1 = utils.hash_file(flo)
|
||||||
h2 = hashlib.sha1(data).hexdigest()
|
h2 = hashlib.sha1(data).hexdigest()
|
||||||
self.assertEqual(h1, h2)
|
self.assertEqual(h1, h2)
|
||||||
|
|
Loading…
Reference in New Issue