Skip to content

Instantly share code, notes, and snippets.

@whimboo
Created Jul 25, 2018
Embed
What would you like to do?
Missing marker in fixturenames for sub-fixture
import pytest
@pytest.fixture(name="fish")
def fixture_fish(taste):
pass
def pytest_generate_tests(metafunc):
if "taste" in metafunc.fixturenames:
print("** found taste")
marker = metafunc.definition.get_closest_marker(name="taste")
if marker:
metafunc.parametrize("taste", marker.args, ids=None)
else:
print("** didn't find taste")
import pytest
@pytest.fixture(name="fish")
def fixture_fish(fish): # , taste):
yield fish
@pytest.mark.taste("dry")
def test_fish(fish):
pass
@whimboo
Copy link
Author

whimboo commented Jul 25, 2018

Without adding taste as argument to the sub-fixture's list of arguments the marker/fixture taste will not be available for the global fish fixture. Means it is not part of metafunc.fixturenames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment