Register the shared fixtures via pytest_plugins

That is the documented way to share fixtures from other modules,
instead of importing them into tests/conftest.py
This commit is contained in:
Alexander Hess 2026-11-30 14:56:11 +01:00
commit aa1a7c796f
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
2 changed files with 8 additions and 45 deletions

View file

@ -12,11 +12,18 @@ from alembic import command as migrations_cmd
from alembic import config as migrations_config
from sqlalchemy import orm
from tests.db import fake_data
from velofy import config
from velofy import db
# Register the shared fixtures in `tests.db.fake_data` here,
# as tests/console/, tests/db/, and tests/forecasts/ use them
pytest_plugins = [
"tests.db.fake_data.fixture_makers",
"tests.db.fake_data.static_fixtures",
]
# The TESTING environment variable is set
# in pyproject.toml in pytest's config section.
if not os.getenv("TESTING"):
@ -100,27 +107,3 @@ def db_session(db_connection):
session.close()
transaction.rollback()
# Import the fixtures from the `fake_data` sub-package.
make_address = fake_data.make_address
make_courier = fake_data.make_courier
make_customer = fake_data.make_customer
make_order = fake_data.make_order
make_replay_order = fake_data.make_replay_order
make_restaurant = fake_data.make_restaurant
address = fake_data.address
city = fake_data.city
city_data = fake_data.city_data
courier = fake_data.courier
customer = fake_data.customer
order = fake_data.order
pre_order = fake_data.pre_order
replayed_order = fake_data.replayed_order
restaurant = fake_data.restaurant
grid = fake_data.grid
pixel = fake_data.pixel
simulation = fake_data.simulation
simulation_data = fake_data.simulation_data

View file

@ -1,21 +1 @@
"""Fixtures for testing the ORM layer with fake data."""
from tests.db.fake_data.fixture_makers import make_address
from tests.db.fake_data.fixture_makers import make_courier
from tests.db.fake_data.fixture_makers import make_customer
from tests.db.fake_data.fixture_makers import make_order
from tests.db.fake_data.fixture_makers import make_replay_order
from tests.db.fake_data.fixture_makers import make_restaurant
from tests.db.fake_data.static_fixtures import address
from tests.db.fake_data.static_fixtures import city
from tests.db.fake_data.static_fixtures import city_data
from tests.db.fake_data.static_fixtures import courier
from tests.db.fake_data.static_fixtures import customer
from tests.db.fake_data.static_fixtures import grid
from tests.db.fake_data.static_fixtures import order
from tests.db.fake_data.static_fixtures import pixel
from tests.db.fake_data.static_fixtures import pre_order
from tests.db.fake_data.static_fixtures import replayed_order
from tests.db.fake_data.static_fixtures import restaurant
from tests.db.fake_data.static_fixtures import simulation
from tests.db.fake_data.static_fixtures import simulation_data