Pytest: Deselecting tests

后端 未结 5 919
臣服心动
臣服心动 2021-01-31 07:28

With pytest, one can mark tests using a decorator

@pytest.mark.slow
def some_slow_test():
    pass

Then, from the command line, one can tell py

5条回答
  •  甜味超标
    2021-01-31 08:17

    It's also possible to stack the mark decorators.

    @pytest.mark.slow
    @pytest.mark.main
    def test_myfunction():
        pass
    

    I then called py.test -m "slow and main" and only the tests with both decorators were called.

    py.test -m "not (slow and main)" resulted in the other tests running

提交回复
热议问题