Skip to content

Commit

Permalink
Fix FixtureDef signature for newer pytest versions
Browse files Browse the repository at this point in the history
In pytest-dev/pytest#1586 the "yieldctx"
argument to FixtureDef was removed.

This uses utils.get_args to check if it's needed or not so pytest-bdd
works on pytest versions before and after that PR.
  • Loading branch information
The-Compiler authored and olegpidsadnyi committed Jun 21, 2016
1 parent f8811bd commit e46e77f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pytest_bdd/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,19 @@ def inject_fixture(request, arg, value):
:param arg: argument name
:param value: argument value
"""
fd = python.FixtureDef(
fixturemanager=request._fixturemanager,
baseid=None,
argname=arg,
func=lambda: value,
scope="function",
params=None,
yieldctx=False,
)
fd_kwargs = {
'fixturemanager': request._fixturemanager,
'baseid': None,
'argname': arg,
'func': lambda: value,
'scope': "function",
'params': None,
}

if 'yieldctx' in get_args(python.FixtureDef.__init__):
fd_kwargs['yieldctx'] = False

fd = python.FixtureDef(**fd_kwargs)
fd.cached_result = (value, 0, None)

old_fd = getattr(request, "_fixturedefs", {}).get(arg)
Expand Down

0 comments on commit e46e77f

Please sign in to comment.