diff --git a/_pytest/python.py b/_pytest/python.py index 8438ca428..88c7d1a39 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1818,7 +1818,7 @@ class FixtureManager: if fixturedef.params is not None: func_params = getattr(getattr(metafunc.function, 'parametrize', None), 'args', [[None]]) # skip directly parametrized arguments - if argname not in func_params and argname not in func_params[0]: + if argname not in func_params: metafunc.parametrize(argname, fixturedef.params, indirect=True, scope=fixturedef.scope, ids=fixturedef.ids) diff --git a/testing/python/collect.py b/testing/python/collect.py index 97250028a..029b0b693 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -412,9 +412,19 @@ class TestFunction: ['overridden']) def test_overridden_via_param(value): assert value == 'overridden' + + @pytest.mark.parametrize('somevalue', ['overridden']) + def test_not_overridden(value, somevalue): + assert value == 'value' + assert somevalue == 'overridden' + + @pytest.mark.parametrize('other,value', [('foo', 'overridden')]) + def test_overridden_via_multiparam(other, value): + assert other == 'foo' + assert value == 'overridden' """) rec = testdir.inline_run() - rec.assertoutcome(passed=1) + rec.assertoutcome(passed=3) def test_parametrize_overrides_parametrized_fixture(self, testdir): diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 8bf738c5d..48f52d2a0 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -1598,6 +1598,22 @@ class TestFixtureMarker: reprec = testdir.inline_run() reprec.assertoutcome(passed=4) + def test_multiple_parametrization_issue_736(self, testdir): + testdir.makepyfile(""" + import pytest + + @pytest.fixture(params=[1,2,3]) + def foo(request): + return request.param + + @pytest.mark.parametrize('foobar', [4,5,6]) + def test_issue(foo, foobar): + assert foo in [1,2,3] + assert foobar in [4,5,6] + """) + reprec = testdir.inline_run() + reprec.assertoutcome(passed=9) + def test_scope_session(self, testdir): testdir.makepyfile(""" import pytest