Browse Source

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
tags/2014.1.b3
tanlin 5 years ago
parent
commit
c85286b882
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      ironic/tests/test_utils.py

+ 2
- 2
ironic/tests/test_utils.py View File

@@ -20,13 +20,13 @@ import errno
20 20
 import hashlib
21 21
 import os
22 22
 import os.path
23
-import StringIO
24 23
 import tempfile
25 24
 import uuid
26 25
 
27 26
 import mock
28 27
 import netaddr
29 28
 from oslo.config import cfg
29
+import six
30 30
 
31 31
 from ironic.common import exception
32 32
 from ironic.common import utils
@@ -233,7 +233,7 @@ class GenericUtilsTestCase(base.TestCase):
233 233
 
234 234
     def test_hash_file(self):
235 235
         data = 'Mary had a little lamb, its fleece as white as snow'
236
-        flo = StringIO.StringIO(data)
236
+        flo = six.StringIO(data)
237 237
         h1 = utils.hash_file(flo)
238 238
         h2 = hashlib.sha1(data).hexdigest()
239 239
         self.assertEqual(h1, h2)

Loading…
Cancel
Save