|
|
@ -1180,8 +1180,9 @@ def test_test_app_proper_environ(): |
|
|
|
assert rv.data == b'Foo SubDomain' |
|
|
|
assert rv.data == b'Foo SubDomain' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_exception_propagation(): |
|
|
|
@pytest.mark.parametrize('config_key', |
|
|
|
def apprunner(configkey): |
|
|
|
['TESTING', 'PROPAGATE_EXCEPTIONS', 'DEBUG', None]) |
|
|
|
|
|
|
|
def test_exception_propagation(config_key): |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app.config['LOGGER_HANDLER_POLICY'] = 'never' |
|
|
|
app.config['LOGGER_HANDLER_POLICY'] = 'never' |
|
|
|
|
|
|
|
|
|
|
@ -1189,26 +1190,22 @@ def test_exception_propagation(): |
|
|
|
def index(): |
|
|
|
def index(): |
|
|
|
1 // 0 |
|
|
|
1 // 0 |
|
|
|
c = app.test_client() |
|
|
|
c = app.test_client() |
|
|
|
|
|
|
|
|
|
|
|
if config_key is not None: |
|
|
|
if config_key is not None: |
|
|
|
app.config[config_key] = True |
|
|
|
app.config[config_key] = True |
|
|
|
try: |
|
|
|
with pytest.raises(Exception): |
|
|
|
c.get('/') |
|
|
|
c.get('/') |
|
|
|
except Exception: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
assert False, 'expected exception' |
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
assert c.get('/').status_code == 500 |
|
|
|
assert c.get('/').status_code == 500 |
|
|
|
|
|
|
|
|
|
|
|
# we have to run this test in an isolated thread because if the |
|
|
|
# If the debug flag is set to true and an exception happens the context |
|
|
|
# debug flag is set to true and an exception happens the context is |
|
|
|
# is not torn down. This causes other tests that run after this fail |
|
|
|
# not torn down. This causes other tests that run after this fail |
|
|
|
|
|
|
|
# when they expect no exception on the stack. |
|
|
|
# when they expect no exception on the stack. |
|
|
|
for config_key in 'TESTING', 'PROPAGATE_EXCEPTIONS', 'DEBUG', None: |
|
|
|
while flask._request_ctx_stack.top is not None: |
|
|
|
t = Thread(target=apprunner, args=(config_key,)) |
|
|
|
flask._request_ctx_stack.pop() |
|
|
|
t.start() |
|
|
|
while flask._app_ctx_stack.top is not None: |
|
|
|
t.join() |
|
|
|
flask._app_ctx_stack.pop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_max_content_length(): |
|
|
|
def test_max_content_length(): |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|