Created
July 25, 2018 10:51
-
-
Save whimboo/6416358017c734533175ec3096e3e41d to your computer and use it in GitHub Desktop.
Missing marker in fixturenames for sub-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 | |
@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") | |
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 | |
@pytest.fixture(name="fish") | |
def fixture_fish(fish): # , taste): | |
yield fish | |
@pytest.mark.taste("dry") | |
def test_fish(fish): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without adding
taste
as argument to the sub-fixture's list of arguments the marker/fixturetaste
will not be available for the globalfish
fixture. Means it is not part ofmetafunc.fixturenames
.