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
|
|
@ -21,19 +21,18 @@ from flask._compat import PY2
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def disable_extwarnings(request, recwarn):
|
||||
def disable_extwarnings(recwarn):
|
||||
from flask.exthook import ExtDeprecationWarning
|
||||
|
||||
def inner():
|
||||
assert set(w.category for w in recwarn.list) \
|
||||
<= set([ExtDeprecationWarning])
|
||||
recwarn.clear()
|
||||
yield
|
||||
|
||||
request.addfinalizer(inner)
|
||||
assert set(w.category for w in recwarn.list) \
|
||||
<= set([ExtDeprecationWarning])
|
||||
recwarn.clear()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def importhook_setup(monkeypatch, request):
|
||||
def importhook_setup(monkeypatch):
|
||||
# we clear this out for various reasons. The most important one is
|
||||
# that a real flaskext could be in there which would disable our
|
||||
# fake package. Secondly we want to make sure that the flaskext
|
||||
|
|
@ -58,12 +57,11 @@ def importhook_setup(monkeypatch, request):
|
|||
import_hooks += 1
|
||||
assert import_hooks == 1
|
||||
|
||||
def teardown():
|
||||
from flask import ext
|
||||
for key in ext.__dict__:
|
||||
assert '.' not in key
|
||||
yield
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
from flask import ext
|
||||
for key in ext.__dict__:
|
||||
assert '.' not in key
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue