"""Shared pytest fixtures for all tests.""" import pytest from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from meshcore_hub.common.models import Base @pytest.fixture def db_engine(): """Create an in-memory SQLite database engine for testing.""" engine = create_engine( "sqlite:///:memory:", connect_args={"check_same_thread": False}, ) Base.metadata.create_all(engine) yield engine Base.metadata.drop_all(engine) engine.dispose() @pytest.fixture def db_session(db_engine): """Create a database session for testing.""" Session = sessionmaker(bind=db_engine) session = Session() yield session session.close()