forked from orbit-oss/flask
deprecate before_first_request
This commit is contained in:
parent
7a2d5fb6df
commit
96c97dec09
6 changed files with 66 additions and 33 deletions
|
|
@ -107,10 +107,12 @@ def test_async_before_after_request():
|
|||
def index():
|
||||
return ""
|
||||
|
||||
@app.before_first_request
|
||||
async def before_first():
|
||||
nonlocal app_first_called
|
||||
app_first_called = True
|
||||
with pytest.deprecated_call():
|
||||
|
||||
@app.before_first_request
|
||||
async def before_first():
|
||||
nonlocal app_first_called
|
||||
app_first_called = True
|
||||
|
||||
@app.before_request
|
||||
async def before():
|
||||
|
|
|
|||
|
|
@ -1684,9 +1684,11 @@ def test_no_setup_after_first_request(app, client):
|
|||
def test_before_first_request_functions(app, client):
|
||||
got = []
|
||||
|
||||
@app.before_first_request
|
||||
def foo():
|
||||
got.append(42)
|
||||
with pytest.deprecated_call():
|
||||
|
||||
@app.before_first_request
|
||||
def foo():
|
||||
got.append(42)
|
||||
|
||||
client.get("/")
|
||||
assert got == [42]
|
||||
|
|
@ -1698,10 +1700,12 @@ def test_before_first_request_functions(app, client):
|
|||
def test_before_first_request_functions_concurrent(app, client):
|
||||
got = []
|
||||
|
||||
@app.before_first_request
|
||||
def foo():
|
||||
time.sleep(0.2)
|
||||
got.append(42)
|
||||
with pytest.deprecated_call():
|
||||
|
||||
@app.before_first_request
|
||||
def foo():
|
||||
time.sleep(0.2)
|
||||
got.append(42)
|
||||
|
||||
def get_and_assert():
|
||||
client.get("/")
|
||||
|
|
|
|||
|
|
@ -722,9 +722,11 @@ def test_app_request_processing(app, client):
|
|||
bp = flask.Blueprint("bp", __name__)
|
||||
evts = []
|
||||
|
||||
@bp.before_app_first_request
|
||||
def before_first_request():
|
||||
evts.append("first")
|
||||
with pytest.deprecated_call():
|
||||
|
||||
@bp.before_app_first_request
|
||||
def before_first_request():
|
||||
evts.append("first")
|
||||
|
||||
@bp.before_app_request
|
||||
def before_app():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue