From 9e5073d39c73a21c8bda94adc737d312346ed3b4 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 22 Feb 2021 23:48:32 +0100 Subject: [PATCH 3/3] tests: allow exceptions to backtrace into tests --- tests/conftest.py | 4 ++++ wcs/qommon/publisher.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 5c6a8173..2ca8c096 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,8 +3,12 @@ from django.utils.six.moves import configparser as ConfigParser import pytest +import wcs.qommon.publisher + from utilities import EmailsMocking, SMSMocking, HttpRequestsMocking +wcs.qommon.publisher.intercept_exceptions = False + def site_options(request, pub, section, variable, value): config = ConfigParser.ConfigParser() diff --git a/wcs/qommon/publisher.py b/wcs/qommon/publisher.py index 8ab133ec..0003df8d 100644 --- a/wcs/qommon/publisher.py +++ b/wcs/qommon/publisher.py @@ -65,6 +65,9 @@ from . import storage from .vendor import locket +intercept_exceptions = True + + class ImmediateRedirectException(Exception): def __init__(self, location): self.location = location @@ -272,6 +275,9 @@ class QommonPublisher(Publisher, object): (exc_type, exc_value, tb) = sys.exc_info() + if not intercept_exceptions: + raise + if exc_type is NotImplementedError: get_response().set_header('Content-Type', 'text/html') # set back content-type return template.error_page(_('This feature is not yet implemented.'), error_title=_('Sorry')) -- 2.30.0