19 lines
450 B
Python
19 lines
450 B
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
import database # noqa: E402
|
|
|
|
|
|
@pytest.fixture
|
|
async def testdb(tmp_path, monkeypatch):
|
|
"""Fresh sqlite file per test; resets the module-global connection."""
|
|
monkeypatch.setattr(database, "DB_PATH", tmp_path / "test.db")
|
|
database._db = None
|
|
await database.init_db()
|
|
yield database
|
|
await database.close_db()
|