1、@pytest.mark.skip(reason=" ") -- 跳过执行测试函数
可传入一个非必须参数reason表示原因
import pytest @pytest.mark.skip(reason="no reason") def test_01(): print("---用例a执行---") class TestCase(): @pytest.mark.skip(reason="no reason") def test_02(self): print("---用例b执行---") def test_03(self): print("---用例c执行---")
输出结果:
test_fixture2.py ss---用例c执行---
2、@pytest.mark.skipif(condition...) -- 若满足condition,则跳过测试函数
传入condition参数为判断条件,可以选择传入非必须参数reason;如果多个标签一起使用,满足其中一个跳过条件则会跳过该测试函数。
import pytest def test_01(): print("---用例a执行---") class TestCase(): #当多个@pytest.mark.skipif()标签时,若满足一个,则跳过测试函数 @pytest.mark.skipif(condition='a' >= 'b', reason="no reason") @pytest.mark.skipif(condition='a' <= 'b', reason="no reason") def test_02(self): print("---用例b执行---") def test_03(self): print("---用例c执行---")
输出结果:
test_fixture2.py ---用例a执行---
.s---用例c执行---
3、自定义@pytest.mark.skip()标签
myskip = pytest.mark.skip() 或 myskip = pytest.mark.skipif(condition=...)
装饰时用该变量代替标签即可:@myskip
import pytest # myskip = pytest.mark.skip() myskip = pytest.mark.skipif(condition=2>1, reason="no reason") @myskip def test_01(): print("---用例a执行---") class TestCase(): @myskip def test_02(self): print("---用例b执行---") def test_03(self): print("---用例c执行---")
输出结果:
test_fixture2.py ss---用例c执行---
4、通过pytest.skip()方法跳过测试函数
import pytest def test_01(): pytest.skip(msg="no reason") print("---用例a执行---") class TestCase(): def test_02(self): pytest.skip() print("---用例b执行---") def test_03(self): print("---用例c执行---")
输出结果:
test_fixture2.py ss---用例c执行--
5、跳过测试类
跳过测试类其实和跳过测试方法一样,使用@pytest.mark.skip()和@pytest.mark.skipif()两个标签,用他们装饰测试类就好啦。
import pytest myskip = pytest.mark.skip(reason="no reason") def test_01(): print("---用例a执行---") @myskip class TestCase(): def test_02(self): print("---用例b执行---") def test_03(self): print("---用例c执行---")
输出结果:
test_fixture2.py ---用例a执行---
6、跳过模块
使用pytestmark(不可更改变量名)变量,让他等于标签即可。
import pytest pytestmark = pytest.mark.skip(condition=2>1, reason='no reason') def test_01(): print("---用例a执行---") class TestCase(): def test_02(self): print("---用例b执行---") def test_03(self): print("---用例c执行---")
输出结果:
test_fixture2.py sss
7、pycharm中运行多个测试文件
依次将要运行的文件名写在后面即可,用逗号隔开,无需链表元组等形式。
if __name__ == "__main__": pytest.main(['-s', 'test_fixture1.py', 'test_fixture2.py'])
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]