How do I disable a test using pytest?

前端 未结 6 1935
终归单人心
终归单人心 2020-12-13 23:49

Let\'s say I have a bunch of tests:

def test_func_one():
    ...

def test_func_two():
    ...

def test_func_three():
    ...

Is there a dec

6条回答
  •  粉色の甜心
    2020-12-14 00:17

    You may also want to run the test even if you suspect that test will fail. For such scenario https://docs.pytest.org/en/latest/skipping.html suggests to use decorator @pytest.mark.xfail

    @pytest.mark.xfail
    def test_function():
        ...
    

    In this case, Pytest will still run your test and let you know if it passes or not, but won't complain and break the build.

提交回复
热议问题