zoukankan      html  css  js  c++  java
  • pytest中xfail、xpass、skip的简单使用

    概述:

    pytest.skip():跳过当前case,这句之前的代码正常执行,之后的不执行

    pytest.xfail():标记当前case为xfail,这句之前的代码正常执行,之后的不执行

    @pytest.mark.xfail:如果被注解的case执行通过,则状态为xpass。如果不通过状态为xfail

    import pytest
    
    
    class TestDemo(object):
    
        @pytest.fixture()
        def error_fixture(self):
            assert 0
    
        def test_ok(self):
            print('ok')
    
    
        def test_fail(self):
            assert 0
    
        def test_error(self, error_fixture):
            pass
    
        def test_skip(self):
            print('before')
            pytest.skip('skip case')
            print('after')
    
        def test_xfail(self):
            print('before')
            pytest.xfail('xfail case')
            print('after')
    
        @pytest.mark.xfail
        def test_xpass(self):
            assert 1
    
    
    if __name__=='__main__':
        pytest.main(['-s', 'test_demo.py'])
    

      

  • 相关阅读:
    bash特性
    FHS 层级文件系统
    环境变量的问题
    linux认识
    搜索引擎的使用
    nginx
    部署操作手册
    git
    添加tag
    pycharm中使用git
  • 原文地址:https://www.cnblogs.com/lybolg/p/14317904.html
Copyright © 2011-2022 走看看