fix teardown bug in FlaskClient

* Fixes pytest-dev/pytest-flask#42
This commit is contained in:
Fantix King 2019-04-16 17:29:17 -05:00 committed by David Lord
parent 754b729578
commit a71c167836
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 29 additions and 6 deletions

View file

@ -411,3 +411,18 @@ def test_cli_custom_obj(app):
runner = app.test_cli_runner()
runner.invoke(hello_command, obj=script_info)
assert NS.called
def test_client_pop_all_preserved(app, req_ctx, client):
@app.route("/")
def index():
# stream_with_context pushes a third context, preserved by client
return flask.Response(flask.stream_with_context("hello"))
# req_ctx fixture pushed an initial context, not marked preserved
with client:
# request pushes a second request context, preserved by client
client.get("/")
# only req_ctx fixture should still be pushed
assert flask._request_ctx_stack.top is req_ctx