[PATCH 5 of 6 signedrequest] [py3, test] Use io.BytesIO instead of StringIO.StringIO

Denis Laxalde denis.laxalde at logilab.fr
Fri Jun 1 12:28:36 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1527845667 -7200
#      Fri Jun 01 11:34:27 2018 +0200
# Node ID c9381a951b78af2c7c6bc0b2b941288c1f93b363
# Parent  84943f333ac07e2b2b6942c57fba6514d517352e
# Available At http://hg.logilab.org/review/cubes/signedrequest
#              hg pull http://hg.logilab.org/review/cubes/signedrequest -r c9381a951b78
# EXP-Topic py3
[py3,test] Use io.BytesIO instead of StringIO.StringIO

diff --git a/test/__init__.py b/test/__init__.py
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -176,7 +176,7 @@ class SignedRequestBaseTC(object):
                    'Date': date}
         # string_to_sign = ('POSThttp://testing.fr/cubicweb/testauth?'
         #                 'key1=value19893532233caff98cd083a116b013c0b%s'%date)
-        body = 'some content'
+        body = b'some content'
         result, req = self._test_header_format(method='Cubicweb',
                                                login='admin',
                                                content=body,
diff --git a/test/test_pyramid.py b/test/test_pyramid.py
--- a/test/test_pyramid.py
+++ b/test/test_pyramid.py
@@ -56,7 +56,7 @@ class PyramidSignedRequestTC(SignedReque
             method=method, headers=headers, **params)
         if http_method == 'POST':
             if content is None:
-                content = "rql=Any+X+WHERE+X+is+Player"
+                content = b"rql=Any+X+WHERE+X+is+Player"
         if content:
             req.body = content
 
diff --git a/test/unittest_authenticate.py b/test/unittest_authenticate.py
--- a/test/unittest_authenticate.py
+++ b/test/unittest_authenticate.py
@@ -16,7 +16,7 @@
 
 "cubicweb-signedrequest automatic tests for authentication"
 
-from StringIO import StringIO
+from io import BytesIO
 
 from cubicweb.devtools.testlib import CubicWebTC, real_error_handling
 
@@ -55,8 +55,8 @@ class SignedRequestTC(SignedRequestBaseT
             # Fill an arbitrary body content if POST.
             if http_method == 'POST':
                 if content is None:
-                    content = "rql=Any+X+WHERE+X+is+Player"
-                req.content = StringIO(content)
+                    content = b"rql=Any+X+WHERE+X+is+Player"
+                req.content = BytesIO(content)
             for name, value in headers.items():
                 req.set_request_header(name, value, raw=True)
             if signature is None:


More information about the cubicweb-devel mailing list