"""pytest 全局配置:确保项目根在 sys.path tests/ 无 __init__.py,pytest prepend 模式只会把 tests/ 加入 sys.path, 直接运行 `pytest` 时 import app 会失败(python -m pytest 因 cwd 入 path 才可用)。 此文件让两种运行方式行为一致。 """ import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent))