mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 20:55:14 +00:00
- Added *.pyc and *.pyo to .gitignore to prevent compiled Python files from being tracked. - Improved docstrings in various modules, providing clearer descriptions of functions, parameters, and return values to enhance code readability and maintainability.
26 lines
578 B
Python
26 lines
578 B
Python
import os
|
|
import sys
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
# 导入 main 模块,确保路径正确
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
|
|
from main import create_app
|
|
|
|
# 创建测试客户端
|
|
app = create_app()
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def test_client():
|
|
"""
|
|
模块级 HTTP 测试客户端(复用同一应用实例与生命周期)。
|
|
|
|
返回:
|
|
- TestClient: 供用例发起的同步测试客户端(yield 注入)。
|
|
"""
|
|
with TestClient(app) as client:
|
|
yield client
|