February 2022
Intermediate to advanced
274 pages
6h 28m
English
With the tests in test_start.py, we added @pytest.mark.<marker_name> decorators to test functions. We can also add markers to entire files or classes to mark multiple tests, or zoom in to parametrized tests and mark individual parametrizations. We can even put multiple markers on a single test. How fun. We’ll use all the mentioned marker types with test_finish.py.
Let’s start with file-level markers:
| | import pytest |
| | from cards import Card, InvalidCardId |
| | |
| | |
| | pytestmark = pytest.mark.finish |
If pytest sees a pytestmark attribute in a test module, it will apply the marker(s) to all the tests in that module. If you want to apply more than one marker to the file, you can ...