'''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")