Closed
Description
This test:
import pytest
@pytest.fixture(params=[1, 2])
def fixt(request):
return request.param
@pytest.mark.parametrize('fixt, val', [(3, 'x'), (4, 'x')])
def test_foo(fixt, val):
pass
works with 2.7.2 but fails since #926 / 41cef6f:
.venv/lib/python3.4/site-packages/pluggy.py:724: in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
.venv/lib/python3.4/site-packages/pluggy.py:338: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
.venv/lib/python3.4/site-packages/pluggy.py:333: in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
.venv/lib/python3.4/site-packages/pluggy.py:595: in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
.venv/lib/python3.4/site-packages/pluggy.py:249: in _wrapped_call
wrap_controller.send(call_outcome)
_pytest/python.py:285: in pytest_pycollect_makeitem
res = list(collector._genfunctions(name, obj))
_pytest/python.py:442: in _genfunctions
self.ihook.pytest_generate_tests(metafunc=metafunc)
.venv/lib/python3.4/site-packages/pluggy.py:724: in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
.venv/lib/python3.4/site-packages/pluggy.py:338: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
.venv/lib/python3.4/site-packages/pluggy.py:333: in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
.venv/lib/python3.4/site-packages/pluggy.py:596: in execute
res = hook_impl.function(*args)
_pytest/python.py:195: in pytest_generate_tests
metafunc.parametrize(*marker.args, **marker.kwargs)
_pytest/python.py:967: in parametrize
param_index)
_pytest/python.py:819: in setmulti
self._checkargnotcontained(arg)
_pytest/python.py:802: in _checkargnotcontained
raise ValueError("duplicate %r" %(arg,))
E ValueError: duplicate 'fixt'
It only seems to fail if:
- The fixture is parametrized
- It's overridden by a parametrized argument
- There is at least one other parametrized argument.
I agree overriding a fixture this way is a bit weird, but I think it should still work.
/cc @untitaker @bubenkoff
by the way - thanks to git bisect this was easy to find out:
git bisect start
git bisect bad master
git bisect good 2.7.2
git bisect run ./.venv/bin/py.test test_foo.py