# HG changeset patch # User Pierre-Yves David # Date 1372070487 -7200 # Node ID 488255d1cf3b36e513b34608f380997c200c5a60 # Parent 1b972d81eda4068e539bb93cde0acd16fd46ce45 [testlib] rework request building in init_authentication The previous code was building a full authenticated request and tried to undo the authentication afterward. The new code just create a bare Request with no authenticated session linked yet. This is much closer of what the actual authentication process does. diff -r 1b972d81eda4 -r 488255d1cf3b devtools/testlib.py --- a/devtools/testlib.py Mon Jun 24 12:39:25 2013 +0200 +++ b/devtools/testlib.py Mon Jun 24 12:41:27 2013 +0200 @@ -768,17 +768,14 @@ def init_authentication(self, authmode, anonuser=None): self.set_auth_mode(authmode, anonuser) - req = self.request(url='login') - origsession = req.session - req.session = req.cnx = None - del req.execute # get back to class implementation + req = self.requestcls(self.vreg, url='login') sh = self.app.session_handler authm = sh.session_manager.authmanager authm.anoninfo = self.vreg.config.anonymous_user() authm.anoninfo = authm.anoninfo[0], {'password': authm.anoninfo[1]} # not properly cleaned between tests self.open_sessions = sh.session_manager._sessions = {} - return req, origsession + return req, self.websession def assertAuthSuccess(self, req, origsession, nbsessions=1): sh = self.app.session_handler diff -r 1b972d81eda4 -r 488255d1cf3b web/test/unittest_application.py --- a/web/test/unittest_application.py Mon Jun 24 12:39:25 2013 +0200 +++ b/web/test/unittest_application.py Mon Jun 24 12:41:27 2013 +0200 @@ -338,7 +338,7 @@ clear_cache(req, 'get_authorization') self.assertTrue('__login' in form) self.assertTrue('__password' in form) - self.assertEqual(req.cnx, None) + self.assertFalse(req.cnx) # Mock cnx are False req.form['__login'] = self.admlogin req.form['__password'] = self.admpassword self.assertAuthSuccess(req, origsession)