Skip to content

Commit 94772f9

Browse files
committed
Remove fix to expose kwargs
1 parent 8fe17df commit 94772f9

File tree

2 files changed

+6
-58
lines changed

2 files changed

+6
-58
lines changed

src/pytest_bdd/scenario.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from __future__ import annotations
1515

1616
import contextlib
17-
import inspect
1817
import logging
1918
import os
2019
import re
@@ -192,31 +191,25 @@ def _execute_step_function(
192191
converters = context.converters
193192
kwargs = {}
194193
args = get_args(context.step_func)
195-
signature = inspect.signature(context.step_func) # Get function signature
196194

197195
try:
198196
parsed_args = context.parser.parse_arguments(step.name)
199197
assert parsed_args is not None, (
200198
f"Unexpected `NoneType` returned from " f"parse_arguments(...) in parser: {context.parser!r}"
201199
)
202200

203-
if step.datatable is not None:
204-
kwargs["datatable"] = step.datatable.raw()
205-
206-
if step.docstring is not None:
207-
kwargs["docstring"] = step.docstring
208-
209201
for arg, value in parsed_args.items():
210202
if arg in converters:
211203
value = converters[arg](value)
212204
kwargs[arg] = value
213205

214-
step_func_explicit_args = {arg: kwargs[arg] if arg in kwargs else request.getfixturevalue(arg) for arg in args}
206+
if step.datatable is not None:
207+
kwargs["datatable"] = step.datatable.raw()
208+
209+
if step.docstring is not None:
210+
kwargs["docstring"] = step.docstring
215211

216-
if any(param.kind == param.VAR_KEYWORD for param in signature.parameters.values()):
217-
kwargs = {**kwargs, **step_func_explicit_args}
218-
else:
219-
kwargs = step_func_explicit_args
212+
kwargs = {arg: kwargs[arg] if arg in kwargs else request.getfixturevalue(arg) for arg in args}
220213

221214
kw["step_func_args"] = kwargs
222215

tests/steps/test_docstring.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -140,51 +140,6 @@ def test_docstring():
140140
result.stdout.fnmatch_lines(["*fixture 'docstring' not found*"])
141141

142142

143-
def test_steps_with_docstring_in_kwargs(pytester):
144-
pytester.makefile(
145-
".feature",
146-
docstring_kwarg=textwrap.dedent(
147-
'''\
148-
Feature: Docstring in kwargs
149-
150-
Scenario: Docstring is in step kwargs
151-
Given this step has a docstring
152-
"""
153-
This is a given docstring
154-
"""
155-
'''
156-
),
157-
)
158-
pytester.makeconftest(
159-
textwrap.dedent(
160-
"""\
161-
from pytest_bdd import given
162-
163-
164-
@given("this step has a docstring")
165-
def _(**kwargs):
166-
print(kwargs['docstring'])
167-
168-
169-
"""
170-
)
171-
)
172-
173-
pytester.makepyfile(
174-
textwrap.dedent(
175-
"""\
176-
from pytest_bdd import scenario
177-
178-
@scenario("docstring_kwarg.feature", "Docstring is in step kwargs")
179-
def test_docstring():
180-
pass
181-
"""
182-
)
183-
)
184-
result = pytester.runpytest("-s")
185-
result.assert_outcomes(passed=1)
186-
187-
188143
def test_steps_with_docstring_missing_argument_in_step_def(pytester):
189144
pytester.makefile(
190145
".feature",

0 commit comments

Comments
 (0)