from __future__ import annotations from collections.abc import Iterator from pathlib import Path import pytest from sqlalchemy.orm import Session from netmover.db import make_engine, make_session_factory, upgrade @pytest.fixture def db_url(tmp_path: Path) -> str: url = f"sqlite:///{tmp_path / 'test.db'}" upgrade(url) return url @pytest.fixture def session(db_url: str) -> Iterator[Session]: engine = make_engine(db_url) factory = make_session_factory(engine) with factory() as s: yield s engine.dispose()