Pytest-skip跳过功能

'''skip跳过用例'''
#pytest.mark.skip可以标记无法在某些平台上运行的测试功能,或者您希望失败的测试功能
#跳过测试函数的最简单方法是使用跳过装饰器标记它,可以传递一个可选的原因
import pytest
# @pytest.mark.skip(reason="想跳过")
# def test_1():
# print("aaaaa")
# @pytest.mark.skip(reason="想跳过")
# def test_2():
# print("bbbb")
#
# def test_function():
# if not valid_config():
# pytest.skip("unsupported configuration")
#
# #可以使用pytest.skip(reason,allow_module_level = True)跳过整个模块级别:
# if not pytest.config.getoption("----custom-flag"):
# pytest.skip("==custom-flag is missing,skipping tests",allow_module_level=True)
#
# if __name__ == '__main__':
# pytest.main(["-s","skip1.py"])

#skipif
import sys
# minversion=pytest.mark.skipif(sys.version_info<(3,6),
# reason="requires python3.6 or higher")
# def test_function():
# print("hhahahah")
#
# def test_function2():
# print("heheheh")
#
# #模块之间共享skip标记
# from skip1 import minversion
# @minversion
# def test_function():
# print("aaaaa")

#可以在类或模块上运行
# @pytest.mark.skipif(sys.platform =='win32',reason="does not run on windwos")
# class TestPosixCalls(object):
# def test_functio(self):
# print("aaaaa")
# def test_func(self):
# print("bbb")



#类名必须大写,skip装饰器名都可以
pytestmar=pytest.mark.skipif(sys.platform =="win32",reason="does not run on windows")
#@pytest.mark.skipif(sys.platform =="win32",reason="does not run on windows")
class Test(object):
def test_1(self):
print("222")
def test_2(self):
print("333")

转载于:https://www.cnblogs.com/nuonuozhou/p/9964664.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值