-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
I just found, accidentally, that this
@pytest.mark.parametrize('request, expected', [(1, 1)])
def test_foo(request, expected):
assert request == expected
would raise an error
...
def get_direct_param_fixture_func(request):
> return request.param
E AttributeError: 'int' object has no attribute 'param'
Wouldn't it be helpful if there was a helpful exception raised here https://github.com/pytest-dev/pytest/blob/master/src/_pytest/fixtures.py#L881-L882?
For example, if
if argname != "request":
fixturedef.addfinalizer(functools.partial(self.finish, request=request))
else:
raise ValueError('`request` cannot be use as a parametrization name')
(or a better message) in the case of the initial example gives
self = <FixtureDef name='request' scope='function' baseid=''>
request = <SubRequest 'request' for <Function 'test_foo[1-1]'>>
def execute(self, request):
# get required arguments and register our own finish()
# with their finalization
for argname in self.argnames:
fixturedef = request._get_active_fixturedef(argname)
if argname != "request":
fixturedef.addfinalizer(functools.partial(self.finish, request=request))
else:
> raise ValueError('`request` cannot be use as a parametrization name')
E ValueError: `request` cannot be use as a parametrization name
The pytest version i'm using is 3.10.0
danieljacobs1
Metadata
Metadata
Assignees
Labels
No labels