Skip to content
Myr

Don't use threads in this test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent 33bad01 · Browse files · 1 file+23 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−26 removed

  • tests:+23 added−26 removed

1 file+23 added−26 removed

modified:tests/test_basic.py+23 added-26 removed
1178 unmodified lines
1179 rv = app.test_client().get('/', 'http://foo.localhost.localdomain')1180 assert rv.data == b'Foo SubDomain'118111821183@pytest.mark.parametrize('config_key',1183def test_exception_propagation():1184 def apprunner(configkey):1185 app = flask.Flask(__name__)1186 app.config['LOGGER_HANDLER_POLICY'] = 'never'1184 ['TESTING', 'PROPAGATE_EXCEPTIONS', 'DEBUG', None])1185def test_exception_propagation(config_key):1186 app = flask.Flask(__name__)1187 app.config['LOGGER_HANDLER_POLICY'] = 'never'11881188 @app.route('/')1189 def index():1190 1 // 01191 c = app.test_client()1192 if config_key is not None:1193 app.config[config_key] = True1194 try:1195 c.get('/')1196 except Exception:1197 pass1198 else:1199 assert False, 'expected exception'1200 else:1201 assert c.get('/').status_code == 5001189 @app.route('/')1190 def index():1191 1 // 01192 c = app.test_client()11931203 # we have to run this test in an isolated thread because if the1204 # debug flag is set to true and an exception happens the context is1205 # not torn down. This causes other tests that run after this fail1206 # when they expect no exception on the stack.1207 for config_key in 'TESTING', 'PROPAGATE_EXCEPTIONS', 'DEBUG', None:1208 t = Thread(target=apprunner, args=(config_key,))1209 t.start()1210 t.join()1194 if config_key is not None:1195 app.config[config_key] = True1196 with pytest.raises(Exception):1197 c.get('/')11981199 else:1200 assert c.get('/').status_code == 50012011202 # If the debug flag is set to true and an exception happens the context1203 # is not torn down. This causes other tests that run after this fail1204 # when they expect no exception on the stack.1205 while flask._request_ctx_stack.top is not None:1206 flask._request_ctx_stack.pop()1207 while flask._app_ctx_stack.top is not None:1208 flask._app_ctx_stack.pop()12091210def test_max_content_length():1211 app = flask.Flask(__name__)1212 app.config['MAX_CONTENT_LENGTH'] = 641213
390 unmodified lines