""" 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)