Sometimes we may want to skip some tests because either 1) the functionality they test is not supported yet Or 2) some versions of the library didn’t support it. We can use one of the following three pytest
markers for this purpose:
pytest.mark.skip
: Skip the test completelypytest.mark.skipif(condition, ...)
: Skip the test if the condition isTrue
pytest.mark.xfail(..., strict=False)
: Run the test even though we know it would fail. Thestrict
option determines if the passed test is classified asXPASSED
ifstrict=False
ORFAILED
ifstrict=True
. If the test failed, it would always returnXFAIL
regardless of thestrict
option.