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")
  • 相关阅读:
    各系统添加根证书
    Nginx浏览目录配置及美化
    django-图形验证码(django-simple-captcha)
    django-manage.py参数
    js — 对象
    js — 数组Array
    js — 字符串
    js — 基础知识
    css — 定位、背景图、水平垂直居中
    css — 权重、继承性、排版、float
  • 原文地址:https://www.cnblogs.com/nuonuozhou/p/9964664.html
Copyright © 2011-2022 走看看