Skip to content

Commit de0f667

Browse files
Merge pull request #183 from The-Compiler/fixturedef
Fix FixtureDef signature for newer pytest versions
2 parents 2f1a185 + 28413e5 commit de0f667

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

pytest_bdd/steps.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,19 @@ def inject_fixture(request, arg, value):
284284
:param arg: argument name
285285
:param value: argument value
286286
"""
287-
fd = python.FixtureDef(
288-
fixturemanager=request._fixturemanager,
289-
baseid=None,
290-
argname=arg,
291-
func=lambda: value,
292-
scope="function",
293-
params=None,
294-
yieldctx=False,
295-
)
287+
fd_kwargs = {
288+
'fixturemanager': request._fixturemanager,
289+
'baseid': None,
290+
'argname': arg,
291+
'func': lambda: value,
292+
'scope': "function",
293+
'params': None,
294+
}
295+
296+
if 'yieldctx' in get_args(python.FixtureDef.__init__):
297+
fd_kwargs['yieldctx'] = False
298+
299+
fd = python.FixtureDef(**fd_kwargs)
296300
fd.cached_result = (value, 0, None)
297301

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

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ basepython=python2.7
2323
deps =
2424
{[testenv]deps}
2525
hg+https://bitbucket.org/pytest-dev/py#egg=py
26-
hg+https://bitbucket.org/pytest-dev/pytest#egg=pytest
26+
git+https://github.com/pytest-dev/pytest.git@features#egg=pytest
2727

2828
[testenv:coveralls]
2929
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH

0 commit comments

Comments
 (0)