summaryrefslogtreecommitdiffstats
path: root/tests/unit/middleware
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2013-05-24 10:35:28 -0500
committerChuck Short <chuck.short@canonical.com>2013-05-31 12:17:38 -0500
commit2bdad357fa19f05a3a579b47578f1510974eb0a4 (patch)
treeec5303886a1155dd931518c93eb1d0ac2d3b7c95 /tests/unit/middleware
parentbabe5fd2f3cb5b3fb08597d537e9a44aa39609bd (diff)
downloadoslo-2bdad357fa19f05a3a579b47578f1510974eb0a4.tar.gz
oslo-2bdad357fa19f05a3a579b47578f1510974eb0a4.tar.xz
oslo-2bdad357fa19f05a3a579b47578f1510974eb0a4.zip
python3: python3 binary/text data compatbility
Python3 enforces the distinction between byte strings far more rigorously than Python 2 does; binary data cannot be automatically coerced to or from text data. Use six to provide a fake file object for textual data. It provides an alias for StringIO.StringIO in python2 and io.StringIO in python3 Change-Id: I65897bb0cca2cbeb5819a769b98645c9eb066401 Signed-off-by: Chuck Short <chuck.short@canonical.com>
Diffstat (limited to 'tests/unit/middleware')
-rw-r--r--tests/unit/middleware/test_sizelimit.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/unit/middleware/test_sizelimit.py b/tests/unit/middleware/test_sizelimit.py
index 500f29d..22098d0 100644
--- a/tests/unit/middleware/test_sizelimit.py
+++ b/tests/unit/middleware/test_sizelimit.py
@@ -13,7 +13,7 @@
# under the License.
from oslo.config import cfg
-import StringIO
+from six import StringIO
import webob
from openstack.common.middleware import sizelimit
@@ -28,14 +28,14 @@ class TestLimitingReader(utils.BaseTestCase):
def test_limiting_reader(self):
BYTES = 1024
bytes_read = 0
- data = StringIO.StringIO("*" * BYTES)
+ data = StringIO("*" * BYTES)
for chunk in sizelimit.LimitingReader(data, BYTES):
bytes_read += len(chunk)
self.assertEquals(bytes_read, BYTES)
bytes_read = 0
- data = StringIO.StringIO("*" * BYTES)
+ data = StringIO("*" * BYTES)
reader = sizelimit.LimitingReader(data, BYTES)
byte = reader.read(1)
while len(byte) != 0:
@@ -49,7 +49,7 @@ class TestLimitingReader(utils.BaseTestCase):
def _consume_all_iter():
bytes_read = 0
- data = StringIO.StringIO("*" * BYTES)
+ data = StringIO("*" * BYTES)
for chunk in sizelimit.LimitingReader(data, BYTES - 1):
bytes_read += len(chunk)
@@ -58,7 +58,7 @@ class TestLimitingReader(utils.BaseTestCase):
def _consume_all_read():
bytes_read = 0
- data = StringIO.StringIO("*" * BYTES)
+ data = StringIO("*" * BYTES)
reader = sizelimit.LimitingReader(data, BYTES - 1)
byte = reader.read(1)
while len(byte) != 0: