forked from orbit-oss/flask
Use the yield syntax in pytest's fixtures
This commit is contained in:
parent
c8e56d5807
commit
5963cb5a51
3 changed files with 25 additions and 28 deletions
|
|
@ -22,16 +22,17 @@ def test_apps(monkeypatch):
|
|||
os.path.dirname(__file__), 'test_apps'))
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def leak_detector(request):
|
||||
def ensure_clean_request_context():
|
||||
# make sure we're not leaking a request context since we are
|
||||
# testing flask internally in debug mode in a few cases
|
||||
leaks = []
|
||||
while flask._request_ctx_stack.top is not None:
|
||||
leaks.append(flask._request_ctx_stack.pop())
|
||||
assert leaks == []
|
||||
request.addfinalizer(ensure_clean_request_context)
|
||||
def leak_detector():
|
||||
yield
|
||||
|
||||
# make sure we're not leaking a request context since we are
|
||||
# testing flask internally in debug mode in a few cases
|
||||
leaks = []
|
||||
while flask._request_ctx_stack.top is not None:
|
||||
leaks.append(flask._request_ctx_stack.pop())
|
||||
assert leaks == []
|
||||
|
||||
|
||||
@pytest.fixture(params=(True, False))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue