- pyproject.toml:pytest/black/isort/mypy 统一配置 - requirements-dev.txt:测试与代码规范开发依赖 - .flake8 / .editorconfig:PEP8 与编辑器统一 - .pre-commit-config.yaml:提交前钩子 - Makefile:常用命令集 - .env.example:环境变量模板(76 键) - tests/:pytest 骨架 + R 响应格式冒烟测试 Co-Authored-By: Claude <noreply@anthropic.com>
20 lines
676 B
Python
20 lines
676 B
Python
"""
|
||
pytest 全局配置
|
||
=============================================================
|
||
|
||
P1 阶段仅搭建骨架,保证 `pytest` 可空跑。
|
||
测试 App 构建、数据库/Redis fixture 在 P8(测试完善阶段)补充:
|
||
- app fixture:create_app() + 测试库 DATABASE_URL 覆盖
|
||
- db fixture:事务内建表/清库
|
||
- client fixture:Flask test_client
|
||
"""
|
||
|
||
import os
|
||
import sys
|
||
|
||
# 项目根目录加入 sys.path(tests/ 已有 __init__.py 时 pytest 通常自动处理,
|
||
# 此处显式补充,兼容从任意目录启动 pytest 的场景)
|
||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
if ROOT not in sys.path:
|
||
sys.path.insert(0, ROOT)
|