zoukankan      html  css  js  c++  java
  • pytest标记预期会失败的测试xfail

    import pytest
    
    class TestClass:
        @pytest.mark.xfail(reason="预期失败")
        def test_one(self):
            assert True
    
        @pytest.mark.xfail(reason="预期失败")
        def test_two(self):
            assert False
    
        def test_three(self):
            assert True
    pytest test_demo5.py
    === test session starts ====
    collected 3 items
    
    test_demo5.py Xx. 

    === 1 passed, 1 xfailed, 1 xpassed in 0.12 seconds ===
    pytest -v test_demo5.py
    === test session starts ===
    collected 3 items
    
    test_demo5.py::TestClass::test_one XPASS                                             
    test_demo5.py::TestClass::test_two XFAIL                                       
    test_demo5.py::TestClass::test_three PASSED                                
    === 1 passed, 1 xfailed, 1 xpassed in 0.08 seconds ===

    x表示XFAIL,预期失败,实际也失败

    X表示XPASS,预期失败,实际运行没有失败

  • 相关阅读:
    day02
    Hive_分区排序(Distribute By)
    flink添加水位线
    SparkSQL读写JDBC
    spark累加器及UDTF
    datax同步json中文乱码问题
    mysql踩过的坑
    spark算子
    spark分区计算方式
    git操作
  • 原文地址:https://www.cnblogs.com/nicole-zhang/p/11139906.html
Copyright © 2011-2022 走看看