[pytest] # 把项目根目录加入导入路径,这样测试里可以写 from src.calculator import ... pythonpath = . # 只在 tests 目录下收集测试 testpaths = tests # 识别为测试文件/类/函数的命名规则(pytest 默认值,写出来方便理解) python_files = test_*.py python_classes = Test* python_functions = test_* # 运行时默认带上的参数:-v 详细输出,-ra 显示测试结果摘要 addopts = -v -ra