[PATCH 11 of 16 eac] [py3] Open form fields values binary mode in tests

Denis Laxalde denis.laxalde at logilab.fr
Tue Oct 1 12:36:37 CEST 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1569921467 -7200
#      Tue Oct 01 11:17:47 2019 +0200
# Node ID 149267ba6a570828b458c519989b0ba172ac53a6
# Parent  6ed322b62fcb9e498ab5763b0fbf40ea75d609e9
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 149267ba6a57
[py3] Open form fields values binary mode in tests

diff --git a/test/test_views.py b/test/test_views.py
index f421a84..d5a0e77 100644
--- a/test/test_views.py
+++ b/test/test_views.py
@@ -15,6 +15,7 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-eac test for views."""
 
+import io
 try:
     import unittest2 as unittest
 except ImportError:
@@ -37,7 +38,7 @@ class FuncViewsTC(CubicWebTC):
         with self.admin_access.web_request() as req:
             # simply test the form properly render and is well formed
             self.view(regid, req=req, template=None)
-            fields = {'file': (fname, open(self.datapath(fname)))}
+            fields = {'file': (fname, io.open(self.datapath(fname), 'rb'))}
             req.form = self.fake_form(regid, fields)
             # now actually test the import
             req.view(regid)
@@ -54,7 +55,7 @@ class FuncViewsTC(CubicWebTC):
         with self.admin_access.web_request() as req:
             # simply test the form properly render and is well formed
             self.view(regid, req=req, template=None)
-            fields = {'file': (fname, open(self.datapath(fname)))}
+            fields = {'file': (fname, io.open(self.datapath(fname), 'rb'))}
             req.form = self.fake_form(regid, fields)
             # now actually test the import
             html = req.view(regid)
@@ -67,7 +68,7 @@ class FuncViewsTC(CubicWebTC):
         regid = 'eac.import'
         fname = 'invalid_xml.xml'
         with self.admin_access.web_request() as req:
-            fields = {'file': (fname, open(self.datapath(fname)))}
+            fields = {'file': (fname, io.open(self.datapath(fname), 'rb'))}
             req.form = self.fake_form(regid, fields)
             # now actually test the import
             html = req.view(regid)
@@ -77,7 +78,7 @@ class FuncViewsTC(CubicWebTC):
         regid = 'eac.import'
         fname = 'missing_tag.xml'
         with self.admin_access.web_request() as req:
-            fields = {'file': (fname, open(self.datapath(fname)))}
+            fields = {'file': (fname, io.open(self.datapath(fname), 'rb'))}
             req.form = self.fake_form(regid, fields)
             # now actually test the import
             html = req.view(regid)



More information about the saem-devel mailing list