Files
FastapiAdmin/backend/tests/conftest.py
T
zhangtao b0ae6af3b1 chore: update .gitignore and enhance docstrings across multiple files
- 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.
2026-04-04 01:21:59 +08:00

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