# HG changeset patch # User Martin Bornhold # Date 2016-07-04 13:46:29 # Node ID 73e7f43f27c654bed0c3d3db9fd6c092dc73bc90 # Parent e62de5c9fb853f5fe1af86b183e3900b55f822f7 tests: Add an autouse fixture to patch the pyro proxy factory. diff --git a/rhodecode/tests/plugin.py b/rhodecode/tests/plugin.py --- a/rhodecode/tests/plugin.py +++ b/rhodecode/tests/plugin.py @@ -285,6 +285,27 @@ def tests_tmp_path(request): return TESTS_TMP_PATH +@pytest.fixture(scope='session', autouse=True) +def patch_pyro_request_scope_proxy_factory(request): + """ + Patch the pyro proxy factory to always use the same dummy request object + when under test. This will return the same pyro proxy on every call. + """ + dummy_request = pyramid.testing.DummyRequest() + + def mocked_call(self, request=None): + return self.getProxy(request=dummy_request) + + patcher = mock.patch( + 'rhodecode.lib.vcs.client.RequestScopeProxyFactory.__call__', + new=mocked_call) + patcher.start() + + @request.addfinalizer + def undo_patching(): + patcher.stop() + + @pytest.fixture def test_repo_group(request): """