test: stabilize full test collection

This commit is contained in:
Vykos
2026-06-04 01:27:29 +02:00
committed by GitHub
parent 271489a10c
commit 5869106089
11 changed files with 125 additions and 7 deletions
+17
View File
@@ -1,8 +1,25 @@
"""Tests for topic keyword matching (src/topic_analyzer.py)."""
import sys
from types import SimpleNamespace
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
def _drop_fake_core_database():
parent = sys.modules.get("core")
attr = getattr(parent, "database", None) if parent is not None else None
mod = sys.modules.get("core.database") or attr
if mod is None or isinstance(getattr(mod, "__file__", None), str):
return
sys.modules.pop("core.database", None)
sys.modules.pop("src.database", None)
if parent is not None and attr is mod:
delattr(parent, "database")
_drop_fake_core_database()
from core.database import Base, Session as DbSession, ChatMessage as DbChatMessage
from core.session_manager import SessionManager
from src.topic_analyzer import analyze_topics