Browse Source

Don't use threads in this test

I think test failures would've been ignored if there were some.

Fixes #1401
pull/1413/head
Markus Unterwaditzer 10 years ago
parent
commit
78cd4161f0
  1. 49
      tests/test_basic.py

49
tests/test_basic.py

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

Loading…
Cancel
Save