August 2018
Beginner
160 pages
4h 8m
English
Marks are created with the @pytest.mark decorator. It works as a factory, so any access to it will automatically create a new mark and apply it to a function. This is easier to understand with an example:
@pytest.mark.slowdef test_long_computation(): ...
By using the @pytest.mark.slow decorator, you are applying a mark named slow to test_long_computation.
Marks can also receive parameters:
@pytest.mark.timeout(10, method="thread")def test_topology_sort(): ...
The @pytest.mark.timeout used in the last example was taken from the pytest-timeout plugin; for more details go to https://pypi.org/project/pytest-timeout/. With this, we define that test_topology_sort should not take more than 10 seconds, in which case it should be terminated ...
Read now
Unlock full access