How do I disable a test using pytest?

前端 未结 6 1943
终归单人心
终归单人心 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-13 23:53

    I'm not sure if it's deprecated, but you can also use the pytest.skip function inside of a test:

    def test_valid_counting_number():
         number = random.randint(1,5)
         if number == 5:
             pytest.skip('Five is right out')
         assert number <= 3
    

提交回复
热议问题