zoukankan      html  css  js  c++  java
  • 标记预期失败

    pytest.ini

    [pytest]
    addopts = -s -v
    testpaths = ./scripts
    python_files = test_case.py
    python_classes = Test*
    python_functions = test_*
    xfail_strict = true

    test_case.py

    import pytest
    def test_case_01():
    assert 1

    class TestCase(object):
    """加装饰器标记预期失败"""
    @pytest.mark.xfail(conditon=1 < 2, reason="xxx")
    def test_case_01(self):
    """预期失败 实际执行结果是失败"""
    assert 0

    @pytest.mark.xfail(condition=1 < 2, reason="ooo")
    def test_case_02(self):
    """预期失败 实际执行结果是成功的"""
    assert {"title":"v2ex"} != {"title": "V2EX"}

    @pytest.mark.skipif(condition=1 > 2, reason="我就想跳过")
    def test_case_03(self):
    assert 0

    if __name__ == '__main__':
    pytest.main(["-s", "test_case.py"])
  • 相关阅读:
    找水王续
    找水王续
    本周学习进度
    Node.js 学习
    在Linux机器上安装MySQL
    ZStack串口通信
    Java编写串口程序
    ServerSocket
    ZigBee毕设
    ZigBee相关网站链接
  • 原文地址:https://www.cnblogs.com/zhang-da/p/12219400.html
Copyright © 2011-2022 走看看