zoukankan      html  css  js  c++  java
  • 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")
  • 相关阅读:
    python 类 专有方法
    当请求进入Nginx后,每个HTTP执行阶段的作用
    jquery 监听不起效果的小问题汇总
    shell 脚本中 while 只执行一次
    LVS (Linux虚拟服务器)模型及算法
    TCP 通信时序及状态变迁
    Golang 谷歌搜索api 实现搜索引擎(前端 bootstrap + jquery)
    Golang 简单 http 代理转发
    Golang 简单静态web服务器
    Golang TCP转发到指定地址
  • 原文地址:https://www.cnblogs.com/nuonuozhou/p/9964664.html
Copyright © 2011-2022 走看看