Don't skip fixtures that are substrings of params

Bug introduced with
https://bitbucket.org/pytest-dev/pytest/pull-requests/257/allow-to-override-parametrized-fixtures

Fix #736
This commit is contained in:
Markus Unterwaditzer 2015-08-08 02:09:08 +02:00
parent 681e502c12
commit 41cef6f5f2
3 changed files with 28 additions and 2 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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