python pytest mark
默认情况下pytest
会测试所有的函数,但是有些时候我们只想测试指定的函数,这就需要用到mark
@pytest.mark.finished
@pytest.mark.unfinished
@pytest.mark.skip 跳过
import pytest
@pytest.mark.finished
def test1_fun():assert 1 == 1@pytest.mark.unfinished
def test2_fun():assert 1 == 1
默认两个方法都测试
PS D:\code\test> pytest test.py
platform win32 -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: D:\code\test, inifile:
plugins: remotedata-0.2.1, openfiles-0.3.0, doctestplus-0.1.3, arraydiff-0.2
collected 2 itemstest.py .. [100%]========================== 2 passed in 0.04 seconds ===========================
只测试finished
PS D:\code\test> pytest -m finished test.py
============================= test session starts =============================
platform win32 -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: D:\code\test, inifile:
plugins: remotedata-0.2.1, openfiles-0.3.0, doctestplus-0.1.3, arraydiff-0.2
collected 2 items / 1 deselectedtest.py . [100%]=================== 1 passed, 1 deselected in 0.05 seconds ====================
只测试unfinished
PS D:\code\test> pytest -m finished test.py
============================= test session starts =============================
platform win32 -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: D:\code\test, inifile:
plugins: remotedata-0.2.1, openfiles-0.3.0, doctestplus-0.1.3, arraydiff-0.2
collected 2 items / 1 deselectedtest.py . [100%]=================== 1 passed, 1 deselected in 0.05 seconds ====================
skip
直接跳过
@pytest.mark.skipif(conn.__version__ < '0.2.0',reason='not supported until v0.2.0')
def test_api():pass
python test.py
https://learning-pytest.readthedocs.io/zh/latest/doc/test-function/skip.html
python pytest mark相关推荐
- python pytest mark.parametrize
虽然可以在测试函数内循环遍历所有参数的可能性,但一旦失败就终止了,即使try结果也比较南分析,所以可以使用pytest.mark.parametrize(argnames, argvalues) # ...
- pytest—pytest.mark.parametrize的使用
一.前言 我们这篇文章呢来讲讲pytest.mark.parametrize的使用,大家都知道Pytest中装饰器@pytest.mark.parametrize('参数名',list)可以实现测试用 ...
- Python Pytest装饰器@pytest.mark.parametrize详解
Pytest中装饰器@pytest.mark.parametrize('参数名',list)可以实现测试用例参数化,类似DDT 如:@pytest.mark.parametrize('请求方式,接口地 ...
- Python Pytest装饰器@pytest.mark.parametrize用例数据驱动(三)
一.测试用例用excel管理,存放地址:C:\Users\wangli\PycharmProjects\Test\test\files\apiCase.xls 二.代码实现如下: 1.封装读取exce ...
- Python Pytest装饰器@pytest.mark.parametrize多样参数化(二)
Pytest中装饰器@pytest.mark.parametrize('参数名',list)可以实现测试用例参数化,类似DDT 1.第一个参数是字符串,多个参数中间用逗号隔开 2.第二个参数是list ...
- Python Pytest调用fixture之@pytest.mark.usefixtures()、叠加usefixtures、@pytest.fixture(autouse=True)用法详解
usefixtures与传fixture区别 如果fixture有返回值,那么usefixture就无法获取到返回值,这个是装饰器usefixture与用例直接传fixture参数的区别. 当fix ...
- python pytest测试框架介绍四----pytest-html插件html带错误截图及失败重测机制
一.html报告错误截图 这次介绍pytest第三方插件pytest-html 这里不介绍怎么使用,因为怎么使用网上已经很多了,这里给个地址给大家参考,pytest-html生成html报告 今天在这 ...
- Pytest标记预期失败得测试用例@pytest.mark.xfail()
pytest除了测试函数中使用这个方法pytest.xfail()外,xfail还有一种使用方法.就是@pytest.mark.xfail()标记预期会失败的用例,即期望测试用例是失败的,但是不会影响 ...
- Pytest跳过执行之@pytest.mark.skip()详解大全
一.skip介绍及运用 在我们自动化测试过程中,经常会遇到功能阻塞.功能未实现.环境等一系列外部因素问题导致的一些用例执行不了,这时我们就可以用到跳过skip用例,如果我们注释掉或删除掉,后面还要进行 ...
最新文章
- advanced search at idiscover
- Python Django 查询数据缓存
- java 框架mvc_JAVA框架-MVC模式
- BugkuCTF-WEB题GET和POST
- matlab数据处理 书,matlab数据处理记录
- 2021年中国以太网测试设备市场趋势报告、技术动态创新及2027年市场预测
- oracle常用的一些sql命令
- 员工请假管理系统(MFC+ACCESS数据库+ODBC数据源)
- android设置主题背景为壁纸_Android 应用背景加载系统动态壁纸
- 中国Linux界五大高手
- 第13章-1~3 法兰接头预紧力密封接触分析(模型简化、网格调整、约束)并行计算设置、摩擦接触设置adjust to touch 、约束设置frictionless support、bolt
- 网络上经常使用的简单投票代码
- Windows11、10,安装最新版ENSP和最新版HCL模拟器教程、无脑下一步!带下载链接
- 【C语言】运算符的优先级
- 服务器系统盘大文件检测指令,服务器系统盘大文件检测指令
- 麻省理工计算机科学硕士,2020年麻省理工学院排名TFE Times美国最佳计算机科学硕士专业排名第4...
- P5017 NOIP2018 普及组 摆渡车
- 操作系统课程设计——Shell编程(用c编写一个Linux的外壳Shell)
- AlarmManager介绍
- koa2中使用jwt
热门文章
- 十堰市人民小学一年级在计算机学校,我上一年级啦!
- iosession在linux下拒绝链接,iosession 关闭
- python grpc 并发_python中grpc的使用示例
- 微课|《Python编程基础与案例集锦(中学版)》第2章(2)
- 微课|中学生可以这样学Python(例4.6):抓小狐狸游戏
- Python使用matplotlib绘制三维曲线
- java outputstream api,Java8 stream API以及常用方法
- php获取时间格式的年份,PHP获取当前时间、时间戳的各种格式写法汇总
- 管理后台--1.创建分类
- microsoftstore连不上网_win10系统下微软商店连不了网如何解决