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"])
原文地址:https://www.cnblogs.com/zhang-da/p/12219400.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。