Skip to content

Commit

Permalink
remove pytest.yield_fixture, it's deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsnolde committed Oct 31, 2023
1 parent 6296f45 commit 6a42c93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from routing_packager_app.worker import create_package


@pytest.yield_fixture(scope="session", autouse=True)
@pytest.fixture(scope="session", autouse=True)
def create_worker():
"""Auto-runs and creates an event loop for the worker."""
worker = Worker([create_package])
Expand All @@ -35,7 +35,7 @@ def get_client(get_app: FastAPI) -> TestClient:
return client


@pytest.yield_fixture(scope="session", autouse=True)
@pytest.fixture(scope="session", autouse=True)
def create_db():
from routing_packager_app.db import engine
from routing_packager_app.api_v1.models import User
Expand All @@ -46,7 +46,7 @@ def create_db():
SQLModel.metadata.drop_all(engine, checkfirst=True)


@pytest.yield_fixture(scope="function")
@pytest.fixture(scope="function")
def get_session():
from routing_packager_app.db import engine

Expand All @@ -69,7 +69,7 @@ def basic_auth_header():


# Creates needed directories and removes them after the test function
@pytest.yield_fixture(scope="session", autouse=True)
@pytest.fixture(scope="session", autouse=True)
def handle_dirs():
paths = [SETTINGS.get_valhalla_path(p) for p in (8002, 8003)]
for p in paths:
Expand Down
6 changes: 3 additions & 3 deletions tests/jobs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
HTTPServer.DEFAULT_LISTEN_HOST = "localhost"


@pytest.yield_fixture(scope="function", autouse=True)
@pytest.fixture(scope="function", autouse=True)
def delete_jobs(get_session: Session):
yield
jobs = get_session.exec(select(Job)).all()
Expand All @@ -23,14 +23,14 @@ def delete_jobs(get_session: Session):
get_session.commit()


@pytest.yield_fixture(scope="function", autouse=True)
@pytest.fixture(scope="function", autouse=True)
def delete_dirs():
yield
for dir_ in SETTINGS.get_output_path().iterdir():
rmtree(dir_)


@pytest.yield_fixture(scope="function")
@pytest.fixture(scope="function")
def copy_valhalla_tiles():
for dir_ in SETTINGS.get_output_path().parent.joinpath("andorra_tiles").iterdir():
copytree(dir_, SETTINGS.get_valhalla_path(8002).joinpath(dir_.stem))
Expand Down

0 comments on commit 6a42c93

Please sign in to comment.