[devtools] accept str objects in CubicWebTC.new_access and .create_user
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 16 Feb 2015 14:30:19 +0100
changeset 10259 2be01bb6f9de
parent 10258 61dfc689830a
child 10260 0e61be7bff10
[devtools] accept str objects in CubicWebTC.new_access and .create_user
devtools/testlib.py
--- a/devtools/testlib.py	Mon Feb 16 10:38:50 2015 +0100
+++ b/devtools/testlib.py	Mon Feb 16 14:30:19 2015 +0100
@@ -315,6 +315,7 @@
         """provide a new RepoAccess object for a given user
 
         The access is automatically closed at the end of the test."""
+        login = unicode(login)
         access = RepoAccess(self.repo, login, self.requestcls)
         self._open_access.add(access)
         return access
@@ -646,9 +647,11 @@
             login = req
             assert not isinstance(self, type)
             req = self._admin_clt_cnx
+        if login is not None:
+            login = unicode(login)
         if password is None:
-            password = login.encode('utf8')
-        user = req.create_entity('CWUser', login=unicode(login),
+            password = login
+        user = req.create_entity('CWUser', login=login,
                                  upassword=password, **kwargs)
         req.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
                     % ','.join(repr(str(g)) for g in groups),