"""Pytest configuration and shared fixtures.

Disposes the global DB engine after each test to avoid ResourceWarning
from unclosed sqlite3 connections when tests touch duty_teller.db.session.
"""

import pytest


@pytest.fixture(autouse=True)
def _dispose_db_engine_after_test():
    """After each test, dispose the global engine so connections are closed."""
    yield
    try:
        import duty_teller.db.session as session_mod

        if session_mod._engine is not None:
            session_mod._engine.dispose()
            session_mod._engine = None
            session_mod._SessionLocal = None
    except Exception:
        pass
