Skip to content

Instantly share code, notes, and snippets.

@whimboo
Created July 25, 2018 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whimboo/6416358017c734533175ec3096e3e41d to your computer and use it in GitHub Desktop.
Save whimboo/6416358017c734533175ec3096e3e41d to your computer and use it in GitHub Desktop.
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