Files
FastapiAdmin/backend/tests/conftest.py
T
zhangtao 53d2a9d13e chore: cleanup old frontend code and update project configs
This commit removes the deprecated frontend/web-old directory, updates various project configuration files including tsconfig, vite config, environment variables, and backend data models. It also fixes several API paths, adds tenant awareness to multiple models, and makes minor UI adjustments.
2026-05-27 01:12:03 +08:00

32 lines
795 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""全局 pytest fixtures — test_client、test_db 等共享夹具。"""
import sys
from pathlib import Path
# 确保 backend 根目录在 Python 路径中
sys.path.insert(0, str(Path(__file__).parent.parent))
import pytest
from fastapi.testclient import TestClient
@pytest.fixture(scope="session")
def test_client() -> TestClient:
"""创建 TestClient 用于 API 测试。
scope=session 确保只创建一次 app,避免 prometheus registry 冲突。
"""
# 清除 prometheus 注册表(避免 Duplicated timeseries
try:
from prometheus_client import REGISTRY
REGISTRY._collector_to_names.clear()
except Exception:
pass
from main import create_app
app = create_app()
with TestClient(app) as client:
yield client