Decorators - Pytest
- In Pytest we can use decorators to add special marks to test functions
- ... or to mark them as fixtures.
examples/decorators/test_with_decorator.py
import sys import pytest @pytest.mark.skipif(sys.platform != 'linux', reason="Linux tests") def test_linux(): assert True @pytest.mark.skip(reason="To show we can skip tests without any condition.") def test_any(): assert True @pytest.fixture(autouse = True, scope="module") def module_demo(): print(f"Fixture")
pytest -v