tests: disable pretty error page handler for tests, with option to
disable when testing error pages, fixes #4208
This commit is contained in:
parent
2ab245bc4b
commit
f9e2cd26fe
3 changed files with 12 additions and 4 deletions
|
|
@ -158,6 +158,8 @@ def load_pyramid_environment(global_config, settings):
|
|||
# This has to be done before the database connection is initialized.
|
||||
if settings['is_test']:
|
||||
rhodecode.is_test = True
|
||||
rhodecode.disable_error_handler = True
|
||||
|
||||
utils.initialize_test_environment(settings_merged)
|
||||
|
||||
# Initialize the database connection.
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ def make_not_found_view(config):
|
|||
except Exception as e:
|
||||
log.exception(e)
|
||||
|
||||
if settings.get('debugtoolbar.enabled', False):
|
||||
if (settings.get('debugtoolbar.enabled', False) or
|
||||
rhodecode.disable_error_handler):
|
||||
raise
|
||||
|
||||
if isinstance(e, VCSCommunicationError):
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
import mock
|
||||
import pytest
|
||||
import rhodecode
|
||||
import rhodecode.lib.vcs.client as client
|
||||
|
||||
@pytest.mark.usefixtures('autologin_user', 'app')
|
||||
|
|
@ -34,9 +35,13 @@ def test_vcs_available_returns_summary_page(app, backend):
|
|||
def test_vcs_unavailable_returns_vcs_error_page(app, backend):
|
||||
url = '/{repo_name}'.format(repo_name=backend.repo.repo_name)
|
||||
|
||||
with mock.patch.object(client, '_get_proxy_method') as p:
|
||||
p.side_effect = client.exceptions.PyroVCSCommunicationError()
|
||||
response = app.get(url, expect_errors=True)
|
||||
try:
|
||||
rhodecode.disable_error_handler = False
|
||||
with mock.patch.object(client, '_get_proxy_method') as p:
|
||||
p.side_effect = client.exceptions.PyroVCSCommunicationError()
|
||||
response = app.get(url, expect_errors=True)
|
||||
finally:
|
||||
rhodecode.disable_error_handler = True
|
||||
|
||||
assert response.status_code == 502
|
||||
assert 'Could not connect to VCS Server' in response.body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue