![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
pytest
文章平均质量分 56
pytest 学习记录
pingerwen
这个作者很懒,什么都没留下…
展开
-
pytest学习记录(八)Fixture
pytest fixture原创 2021-04-23 21:24:20 · 271 阅读 · 0 评论 -
pytest学习记录(七)参数化测试
使用@pytest.mark.parametrize(argnames, argvalues, indirect=False, ids=None, scope=None)对测试进行参数化1、常用参数:argnames:参数名 argvalues:参数对应值,类型必须为list 当参数为一个时格式:[value] 当参数个数大于一个时,格式为:[(param_value1,param_value2.....),(原创 2021-04-22 16:53:38 · 91 阅读 · 0 评论 -
pytest学习记录(六)运行测试子集
通过 node id 运行测试子集运行pytest搜索路径下所有用例: pytest运行单个目录: pytest 目录名称运行单个测试文件/模块:pytest 文件名运行单个类:pytest 文件名::类名运行类中的测试方法:pytest 文件名::类名::函数名运行单个用例(测试函数):pytest 文件名::函数名通过关键字表达式过滤执行用测试名划分测试集合: pytest -k 测试名 (and or not ),过滤并运行“测试模块名、测试类名或测试函数名”中包含关键字的..原创 2021-04-22 15:34:44 · 177 阅读 · 0 评论 -
pytest 学习记录(五)标记测试用例(skip skipif xfail)
示例代码:# -*- coding: utf-8 -*-import unittestimport pytestfrom mudules.mudules import skip1, skipif1, run_these_pleaseclass TestDemo(unittest.TestCase): # @skipif1 # pytest.mark.skipif(1 + 1 == 2, reason='跳过') 在mudules.mudules中定义的 @skip1 # skip1原创 2021-04-21 21:40:56 · 203 阅读 · 0 评论 -
pytest学习记录(四) pytest的配置文件
Pytest配置文件配置文件pytest.inipytest的主配置文件,可以改变pytest的默认行为,通常放在测试目录下,名称为pytest.ini,命令行运行时会使用该配置文件中的配置.pytest.ini 文件内容如下:[pytest] addopts = -s -v ... #设置命令行参数 空格分隔,可添加多个命令行参数 testpaths = ./scripts #配置测试搜索的路径 当前目录下的scripts文件夹 -可自定义python_fi原创 2021-04-21 20:47:29 · 536 阅读 · 0 评论 -
pytest学习记录(三) 测试用例的默认搜索规则
默认规则pytest 默认测试文件命名规则:test_*.py 或者*_test.pypytest 默认测试类名命名规则:Test* 开头,并且类中不能带有 init 方法pytest 默认测试函数、类方法命名规则:test_* 开头自定义规则若想修改默认名称,可在pytest.ini文件中指定,例子如下:[pytest] testpaths = ./scripts #配置测试搜索的路径 搜索当前目录下的scripts文件夹 python_files = ido*.p原创 2021-04-21 17:31:26 · 233 阅读 · 0 评论 -
pytest 学习记录 (二) 常用命令行参数
常用命令行参数获取帮助信息-h,--help #获取帮助信息--version #获取版本信息对用例执行的调控--collect-only #收集并显示将执行的测试用例,仅收集用例,不会执行用例-k #选择你想执行的测试用例 pytest -k "test_test01 or test_case_demo1"-m #运行已标记的用例 @pytest.mark.run_these_please # 对用例(test_case_demo1)进行标记 test_case_d原创 2021-04-21 17:15:28 · 180 阅读 · 1 评论 -
pytest 学习记录(一) 安装pytest
pytest 安装官方文档:https://docs.pytest.org/安装前置条件Pythons:pytest要求:Python 3.6、3.7、3.8、3.9或PyPy3。安装建议使用虚拟环境 ,在虚拟环境中安装pytest,以满足项目对不同版本插件的需求虚拟环境安装见:https://blog.csdn.net/qq_28825969/article/details/115956954?spm=1001.2014.3001.5501也可参考https://packaging.pyt原创 2021-04-21 16:51:37 · 1076 阅读 · 0 评论