22 lines
676 B
Python
22 lines
676 B
Python
import os
|
|
import sys
|
|
import pytest
|
|
|
|
# Add project root and src/ to path so bigmind and server tools are importable
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def temp_db(tmp_path, monkeypatch):
|
|
"""Redirect every test to a fresh temporary database."""
|
|
db_file = tmp_path / "test_memory.db"
|
|
monkeypatch.setenv("BIGMIND_DB_PATH", str(db_file))
|
|
monkeypatch.setenv("BIGMIND_USER", "testuser")
|
|
|
|
# Re-initialise DB with the new path
|
|
from bigmind.db import init_db
|
|
init_db()
|
|
yield db_file
|
|
|