在pytest提供的终端运行测试用例的方式的基础上,pytest还支持使用配置文件来简化运行参数。可以通过pytest --help 查看pytest配置文件的名:pytest.ini \tox.ini\setup.cfg.CI持续集成(setup.cfg) git commit 配置文件一般保存在项目根目录下。
添加配置文件pytest.ini
[pytest] addopts =-s -v testpaths = ./ python_files = test_*.py python_classes = Test* python_functions = test_*
[pytest]:命名空间,表示以下选项属于pytest配置
addopts:运行参数
testpaths:匹配搜索测试文件的目录和路径
python_files:匹配搜索测试文件名格式
python_classes:匹配搜索测试类格式
python_functions:匹配搜索测试方法名格式
执行结果如下:
标签:基于,匹配,配置文件,python,pytest,搜索,ini From: https://www.cnblogs.com/anhao-world/p/16633861.html