fix: 测试库按进程隔离,主题在无法写存储时仍能打开
This commit is contained in:
@@ -9,7 +9,7 @@ sys.path.insert(0, str(_backend))
|
||||
_root = _backend.parent / "Temp" / "pytest"
|
||||
_root.mkdir(parents=True, exist_ok=True)
|
||||
os.environ["EUNIV_SECRET_KEY"] = "test-secret-key-0123456789abcdef"
|
||||
os.environ["EUNIV_DB_PATH"] = str(_root / "euniv.db")
|
||||
os.environ["EUNIV_DB_PATH"] = str(_root / f"euniv-{os.getpid()}.db")
|
||||
os.environ["EUNIV_DISABLE_REFRESH"] = "1"
|
||||
os.environ["EUNIV_ADMIN_PASSWORD"] = "test-admin-pass"
|
||||
os.environ["EUNIV_COOKIE_SECURE"] = "0"
|
||||
@@ -22,15 +22,11 @@ def fresh_database():
|
||||
|
||||
from admin.settings import ensure_admin_seed, ensure_key_check, load_admin_identity
|
||||
from euniv.db import engine, init_db
|
||||
from euniv.models import Base
|
||||
import admin.models # noqa: F401
|
||||
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
with engine.begin() as connection:
|
||||
connection.execute(text("DROP TABLE IF EXISTS accounts"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS system_config"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS courses"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS course_sync"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS proxy_nodes"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS proxy_pool_sync"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS finished_courses"))
|
||||
connection.execute(text("DROP TABLE IF EXISTS alembic_version"))
|
||||
init_db()
|
||||
ensure_admin_seed()
|
||||
|
||||
Reference in New Issue
Block a user