Using Builtin Markers
pytest’s builtin markers are used to modify the behavior of how tests run. We explored @pytest.mark.parametrize() in the last chapter. Here’s the full list of the builtin markers included in pytest as of pytest 6:
- @pytest.mark.filterwarnings(warning): This marker adds a warning filter to the given test.
- @pytest.mark.skip(reason=None): This marker skips the test with an optional reason.
- @pytest.mark.skipif(condition, ..., *, reason): This marker skips the test if any of the conditions are True.
- @pytest.mark.xfail(condition, ..., *, reason, run=True, raises=None, strict=xfail_strict): This marker tells pytest that we expect the test to fail.
- @pytest.mark.parametrize(argnames, argvalues, indirect, ids, scope): This marker ...