Last active
October 18, 2021 16:59
-
-
Save jonashaag/3554b7ffc0d61d60b38e44a12b62bc7d to your computer and use it in GitHub Desktop.
pytest mark a fixture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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