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'])
    

      

  • 相关阅读:
    JS-15 (class)
    JS-14 (解构)
    AI CycleGAN
    AI GAN
    AI StarGAN
    AI VGG
    硬件 PCIe总线
    工具 docker
    MySql开启慢速查询日志
    AI StyleGAN
  • 原文地址:https://www.cnblogs.com/lybolg/p/14317904.html
Copyright © 2011-2022 走看看