Skip to content

Instantly share code, notes, and snippets.

@jonashaag
Last active October 18, 2021 16:59
Show Gist options
  • Save jonashaag/3554b7ffc0d61d60b38e44a12b62bc7d to your computer and use it in GitHub Desktop.
Save jonashaag/3554b7ffc0d61d60b38e44a12b62bc7d to your computer and use it in GitHub Desktop.
pytest mark a fixture
import pytest
def mark_fixture(mark, *args, **kwargs):
"""Decorator to mark a fixture.
Usage:
@mark_fixture(pytest.mark.slow, scope="session", ...)
def my_fixture():
...
def test_xyz(my_fixture):
# This test will be marked slow.
...
"""
return pytest.fixture(*args, **kwargs, params=[pytest.param("dummy", marks=mark)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment