Python 官方文档:入门教程 => 点击学习
目录一、pytest.ini说明二、pytest.ini设置1.addopts–设置自定义执行参数2. testpaths–设置执行路径3. markers&
pytest运行时以此设置为默认执行条件
代码如下(示例):
[pytest]
# 命令行参数,用空格分隔
addopts = -v -s --reruns 1 --html=report.html
说明:
注意:当ini配置文件的参数与run文件里的命令参数重复时,命令行的参数值会覆盖ini配置文件中定义的参数值
代码如下(示例):
[pytest]
# 读取测试用例的起始文件夹,多个路径用空格分隔。注意:这些目录下不能出现相同文件名,否则会报错
testpaths = ./testcase
代码如下(示例):
[pytest]
markers =
smoking :
high :
medium :
lower :
测试用例中标识,运行pytest -v -m smoking,只执行含有smoking标记的测试用例
代码如下(示例):
@pytest.mark.smoking
def test_01():
pass
pytest 默认查找用例匹配规则:
如果我们想匹配以My_*.py的文件,在 pytest.ini 文件添加一项 python_files 即可
[pytest]
Python_files = My_*.py
到此这篇关于pytest中配置文件pytest.ini使用的文章就介绍到这了,更多相关pytest pytest.ini内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: pytest中配置文件pytest.ini使用
本文链接: https://www.lsjlt.com/news/118345.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0