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:
parent
681e502c12
commit
41cef6f5f2
|
@ -1818,7 +1818,7 @@ class FixtureManager:
|
||||||
if fixturedef.params is not None:
|
if fixturedef.params is not None:
|
||||||
func_params = getattr(getattr(metafunc.function, 'parametrize', None), 'args', [[None]])
|
func_params = getattr(getattr(metafunc.function, 'parametrize', None), 'args', [[None]])
|
||||||
# skip directly parametrized arguments
|
# 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,
|
metafunc.parametrize(argname, fixturedef.params,
|
||||||
indirect=True, scope=fixturedef.scope,
|
indirect=True, scope=fixturedef.scope,
|
||||||
ids=fixturedef.ids)
|
ids=fixturedef.ids)
|
||||||
|
|
|
@ -412,9 +412,19 @@ class TestFunction:
|
||||||
['overridden'])
|
['overridden'])
|
||||||
def test_overridden_via_param(value):
|
def test_overridden_via_param(value):
|
||||||
assert value == 'overridden'
|
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 = testdir.inline_run()
|
||||||
rec.assertoutcome(passed=1)
|
rec.assertoutcome(passed=3)
|
||||||
|
|
||||||
|
|
||||||
def test_parametrize_overrides_parametrized_fixture(self, testdir):
|
def test_parametrize_overrides_parametrized_fixture(self, testdir):
|
||||||
|
|
|
@ -1598,6 +1598,22 @@ class TestFixtureMarker:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=4)
|
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):
|
def test_scope_session(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
Loading…
Reference in New Issue