February 2022
Intermediate to advanced
274 pages
6h 28m
English
In this chapter, we looked at custom markers, builtin markers, and how to use markers to pass data to fixtures. We also covered a few new options and changes to pytest.ini.
Here’s an example pytest.ini file:
| | [pytest] |
| | markers = |
| | <marker_name>: <marker_description> |
| | <marker_name>: <marker_description> |
| | addopts = |
| | --strict-markers |
| | -ra |
| | |
| | xfail_strict = true |
Custom markers are declared with the markers section.
The --strict-markers flag tells pytest to raise an error if it sees us using an undeclared marker. The default is a warning.
The -ra flag tells pytest to list the reason for any test that isn’t passing. This includes fail, error, skip, xfail, and xpass.
Setting xfail_strict = true turns any passing tests marked ...
Read now
Unlock full access