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: Icffbbc8b1fcbf2003f7206530c4cd13fd376a59a
Closes-Bug: #1280100
tags/2014.2.b1
He Yongli 5 years ago
parent
commit
0077f4afc2
2 changed files with 5 additions and 2 deletions
  1. 2
    0
      test-requirements.txt
  2. 3
    2
      trove/tests/unittests/api/common/test_limits.py

+ 2
- 0
test-requirements.txt View File

@@ -17,3 +17,5 @@ mox>=0.5.3
17 17
 testtools>=0.9.34
18 18
 discover
19 19
 testrepository>=0.0.18
20
+six>=1.6.0
21
+

+ 3
- 2
trove/tests/unittests/api/common/test_limits.py View File

@@ -18,12 +18,13 @@ Tests dealing with HTTP rate-limiting.
18 18
 """
19 19
 
20 20
 import httplib
21
-import StringIO
22 21
 from trove.quota.models import Quota
23 22
 import testtools
24 23
 import webob
25 24
 
26 25
 from mock import Mock, MagicMock
26
+import six
27
+
27 28
 from trove.common import limits
28 29
 from trove.common.limits import Limit
29 30
 from trove.limits import views
@@ -559,7 +560,7 @@ class FakeHttplibSocket(object):
559 560
 
560 561
     def __init__(self, response_string):
561 562
         """Initialize new `FakeHttplibSocket`."""
562
-        self._buffer = StringIO.StringIO(response_string)
563
+        self._buffer = six.StringIO(response_string)
563 564
 
564 565
     def makefile(self, _mode, _other):
565 566
         """Returns the socket's internal buffer."""

Loading…
Cancel
Save