[devtools] make CubicWebTC.login as admin undo previous logins
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 14 Jan 2014 17:30:02 +0100
changeset 9473 53974a06d646
parent 9472 ae97167956b1
child 9474 dd96b877879d
[devtools] make CubicWebTC.login as admin undo previous logins Fixes things when login is not used as a context manager.
devtools/testlib.py
--- a/devtools/testlib.py	Tue Jan 14 17:30:13 2014 +0100
+++ b/devtools/testlib.py	Tue Jan 14 17:30:02 2014 +0100
@@ -337,8 +337,9 @@
         """return a connection for the given login/password"""
         __ = kwargs.pop('autoclose', True) # not used anymore
         if login == self.admlogin:
-            # definitly don't want autoclose when used as a context manager
-            clt_cnx = repoapi.ClientConnection(self._admin_session)
+            # undo any previous login, if we're not used as a context manager
+            self.restore_connection()
+            return self.cnx
         else:
             if not kwargs:
                 kwargs['password'] = str(login)