前言
pytest配置文件可以改变pytest的运行方式,它是一个固定的文件pytest.ini文件,读取配置信息,按指定的方式去运行。
ini配置文件
pytest里面有些文件是非test文件
- pytest.ini pytest的主配置文件,可以改变pytest的默认行为
- conftest.py 测试用例的一些fixture配置
- _init_.py 识别该文件夹为python的package包
- tox.ini 与pytest.ini类似,用tox工具时候才有用
- setup.cfg 也是ini格式文件,影响setup.py的行为
ini文件基本格式
# 保存为pytest.ini文件
[pytest]
addopts = -rsxX
xfail_strict = true
使用pytest --help指令可以查看pytest.ini的设置选项
[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:
markers (linelist) markers for test functions
empty_parameter_set_mark (string) default marker for em