diff --git a/rhodecode/tests/vcs/test_client_http.py b/rhodecode/tests/vcs/test_client_http.py --- a/rhodecode/tests/vcs/test_client_http.py +++ b/rhodecode/tests/vcs/test_client_http.py @@ -76,12 +76,15 @@ def test_repo_maker_uses_session_for_ins 'http://server_and_port/endpoint', data=mock.ANY) +@mock.patch('rhodecode.lib.vcs.client_http.ThreadlocalSessionFactory') @mock.patch('rhodecode.lib.vcs.connection') -def test_connect_passes_in_the_same_session(connection, stub_session): - session_factory_patcher = mock.patch.object( - vcs, '_create_http_rpc_session', return_value=stub_session) - with session_factory_patcher: - vcs.connect_http('server_and_port') - assert connection.Hg._session == stub_session - assert connection.Svn._session == stub_session - assert connection.Git._session == stub_session +def test_connect_passes_in_the_same_session(connection, session_factory_class, + stub_session): + session_factory = session_factory_class.return_value + session_factory.return_value = stub_session + + vcs.connect_http('server_and_port') + + assert connection.Hg._session_factory() == stub_session + assert connection.Svn._session_factory() == stub_session + assert connection.Git._session_factory() == stub_session