Fix @pytest.yield_fixture deprecation

Use @pytest.fixture instead; they are the same.
This commit is contained in:
sayali 2021-01-05 18:14:57 -08:00
parent 8f16402c0a
commit 396e3afdfa
1 changed files with 6 additions and 6 deletions

View File

@ -56,7 +56,7 @@ def pytest_runtest_makereport(item, call):
parent._previousfailed = item parent._previousfailed = item
@pytest.yield_fixture(scope="session") @pytest.fixture(scope="session")
def app(request): def app(request):
""" """
Creates a new Flask application for a test duration. Creates a new Flask application for a test duration.
@ -73,7 +73,7 @@ def app(request):
ctx.pop() ctx.pop()
@pytest.yield_fixture(scope="session") @pytest.fixture(scope="session")
def db(app, request): def db(app, request):
_db.drop_all() _db.drop_all()
_db.engine.execute(text("CREATE EXTENSION IF NOT EXISTS pg_trgm")) _db.engine.execute(text("CREATE EXTENSION IF NOT EXISTS pg_trgm"))
@ -92,7 +92,7 @@ def db(app, request):
_db.drop_all() _db.drop_all()
@pytest.yield_fixture(scope="function") @pytest.fixture(scope="function")
def session(db, request): def session(db, request):
""" """
Creates a new database session with (with working transaction) Creates a new database session with (with working transaction)
@ -103,7 +103,7 @@ def session(db, request):
db.session.rollback() db.session.rollback()
@pytest.yield_fixture(scope="function") @pytest.fixture(scope="function")
def client(app, session, client): def client(app, session, client):
yield client yield client
@ -276,14 +276,14 @@ def source_plugin():
return TestSourcePlugin return TestSourcePlugin
@pytest.yield_fixture(scope="function") @pytest.fixture(scope="function")
def logged_in_user(session, app): def logged_in_user(session, app):
with app.test_request_context(): with app.test_request_context():
identity_changed.send(current_app._get_current_object(), identity=Identity(1)) identity_changed.send(current_app._get_current_object(), identity=Identity(1))
yield yield
@pytest.yield_fixture(scope="function") @pytest.fixture(scope="function")
def logged_in_admin(session, app): def logged_in_admin(session, app):
with app.test_request_context(): with app.test_request_context():
identity_changed.send(current_app._get_current_object(), identity=Identity(2)) identity_changed.send(current_app._get_current_object(), identity=Identity(2))