mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-20 20:39:55 +00:00
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.
32 lines
795 B
Python
32 lines
795 B
Python
"""全局 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
|