Skip to content
Source

PyTest Tricks

Annotating Tests

import pytest

@pytest.mark.slow
def test_that_runs_slowly():
    ...

@pytest.mark.data
def test_that_goes_on_data():
    ...

@pytest.mark.slow
@pytest.mark.data
def test_that_goes_on_data_slowly():
    ...
> py.test -m "slow"
> py.test -m "data"
> py.test -m "not data"

Source: Eric Ma - Blog