-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
topic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetype: proposalproposal for a new feature, often to gather opinions or design the API around the new featureproposal for a new feature, often to gather opinions or design the API around the new feature
Description
Originally reported by: Florian Rathgeber (BitBucket: frathgeber, GitHub: frathgeber)
I often have a use case like the following contrived example:
@pytest.fixture
def a():
return 'a'
@pytest.fixture
def b():
return 'b'
@pytest.mark.parametrize('arg', [a, b])
def test_foo(arg):
assert len(arg) == 1
This doesn't currently do what's intended i.e. arg
inside the test function is not the fixture value but the fixture function.
I can work around it by introducing a "meta fixture", but that's rather ugly:
@pytest.fixture(params=['a', 'b'])
def arg(request, a, b):
return {'a': a, 'b': b}[request.param]
def test_foo(arg):
assert len(arg) == 1
It would be convenient if a syntax like in the first case was supported.
laurentsenta, corydodt, aarimond, michael-k, jbasko and 565 moredkunitsk, heckad, aplz, mikewojnowicz, vetalpaprotsky and 9 morewooyek, webknjaz, smbdsbrain, dkunitsk, webyneter and 15 moreazalea, antonio-antuan, robsdedude, nathanielatom, wooyek and 50 morevetalpaprotsky, yunbang-app, thales-maciel, bertsons, dokshina and 10 morenkonin, dokshina, Congee, DominicFrei, rawrgulmuffins and 8 more
Metadata
Metadata
Assignees
Labels
topic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetype: proposalproposal for a new feature, often to gather opinions or design the API around the new featureproposal for a new feature, often to gather opinions or design the API around the new feature