Commit caf9b4c1 authored by David Douard's avatar David Douard
Browse files

[py3k] use BytesIO instead of StringIO

parent 1fa5e2c98fce
......@@ -3,7 +3,7 @@ import sys
from os.path import join, dirname, abspath
from socket import gethostname
from StringIO import StringIO
from io import BytesIO
from logilab.common.testlib import unittest_main
from cwclientlib import cwproxy
......@@ -182,7 +182,7 @@ class ReplyCommentHooksTC(CubicWebServerTC):
mi = Importer(cwproxy.CWProxy(self.config['base-url'],
auth=cwproxy.SignedRequestAuth(self.token_id,
self.secret)))
mi.import_mbox_stream(StringIO(msg))
mi.import_mbox_stream(BytesIO(msg.encode('utf-8')))
with self.admin_access.client_cnx() as cnx:
self.assertTrue(cnx.execute('Email X'))
b = cnx.entity_from_eid(self.b)
......
......@@ -4,7 +4,7 @@ import sys
from os import mkdir
from os.path import join, dirname, exists, abspath
from StringIO import StringIO
from io import BytesIO
from logilab.common.testlib import TestCase, unittest_main
from cwclientlib import cwproxy
......@@ -89,7 +89,7 @@ http://lists.logilab.org/mailman/listinfo/python-projects''')
self.assertEqual(part2.content_format,'text/plain')
NOSUBJECT = """
NOSUBJECT = b"""
From python-projects-bounces@lists.logilab.org Tue Mar 28 17:06:41 2006
Return-Path: <python-projects-bounces@lists.logilab.org>
X-Original-To: sylvain.thenault@logilab.fr
......@@ -202,7 +202,7 @@ http://lists.logilab.org/mailman/listinfo/python-projects
def test_no_subject(self):
mi = Importer(cwproxy.CWProxy(self.config['base-url'], auth=cwproxy.SignedRequestAuth(self.token_id, self.secret)))
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
mi.import_mbox_stream(BytesIO(self.NOSUBJECT))
with self.admin_access.client_cnx() as cnx:
rset = cnx.execute('Any X ORDERBY S WHERE X is Email, X subject S')
self.assertEqual(len(rset), 1)
......@@ -212,8 +212,8 @@ http://lists.logilab.org/mailman/listinfo/python-projects
def test_double_import(self):
mi = Importer(cwproxy.CWProxy(self.config['base-url'], auth=cwproxy.SignedRequestAuth(self.token_id, self.secret)))
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
mi.import_mbox_stream(BytesIO(self.NOSUBJECT))
mi.import_mbox_stream(BytesIO(self.NOSUBJECT))
with self.admin_access.client_cnx() as cnx:
rset = cnx.execute('Any X, S ORDERBY S WHERE X is Email, X subject S')
self.assertEqual(len(rset), 1, rset.rows)
......@@ -235,7 +235,7 @@ http://lists.logilab.org/mailman/listinfo/python-projects
#self.assertEqual(testrset[0][0], eid2)
cnx.commit()
mi = Importer(cwproxy.CWProxy(self.config['base-url'], auth=cwproxy.SignedRequestAuth(self.token_id, self.secret)))
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
mi.import_mbox_stream(BytesIO(self.NOSUBJECT))
with self.admin_access.client_cnx() as cnx:
rset = cnx.execute('Any X ORDERBY S WHERE X is Email, X subject S')
self.assertEqual(len(rset), 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment