Skip to content

Commit c9d451b

Browse files
pre-commit-ci[bot]arunpkm
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0959385 commit c9d451b

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/pytest_bdd/scenario.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ def _execute_step_function(
162162
raise
163163

164164
if context.target_fixture is not None:
165-
target_fixture_tokens = [token for token in context.target_fixture.split(',') if token]
165+
target_fixture_tokens = [token for token in context.target_fixture.split(",") if token]
166166
return_values = (return_value,) if not isinstance(return_value, tuple) else return_value
167-
assert len(target_fixture_tokens) == len(return_values), f"Return value count: {len(return_values)} are not matching target_fixture count: {len(target_fixture_tokens)}"
167+
assert len(target_fixture_tokens) == len(
168+
return_values
169+
), f"Return value count: {len(return_values)} are not matching target_fixture count: {len(target_fixture_tokens)}"
168170
for token, value in zip(target_fixture_tokens, return_values):
169171
inject_fixture(request, token, value)
170172

tests/steps/test_given.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import textwrap
33

44

5-
def test_given_injection(pytester):
5+
def test_given_injection_single_value(pytester):
66
pytester.makefile(
77
".feature",
88
given=textwrap.dedent(
@@ -40,15 +40,15 @@ def _(foo):
4040
result.assert_outcomes(passed=1)
4141

4242

43-
def test_given_injection_multiple(pytester):
43+
def test_given_injection_multiple_values(pytester):
4444
pytester.makefile(
4545
".feature",
4646
given=textwrap.dedent(
4747
"""\
4848
Feature: Given
4949
Scenario: Test given fixture injection
50-
Given I have injecting given
51-
Then foo should be "injected foo"
50+
Given I have injecting given values
51+
Then values should be received
5252
"""
5353
),
5454
)
@@ -62,18 +62,19 @@ def test_given_injection_multiple(pytester):
6262
def test_given():
6363
pass
6464
65-
@given("I have injecting given", target_fixture="foo,bar")
65+
@given("I have injecting given values", target_fixture="foo,city,numbers")
6666
def _():
67-
return "injected foo", "injected bar"
67+
return ("injected foo", {"city": ["Boston", "Houston"]}, [10,20,30],)
6868
6969
70-
@then('foo should be "injected foo"')
71-
def _(foo, bar):
70+
@then("values should be received")
71+
def _(foo, city, numbers):
7272
assert foo == "injected foo"
73-
assert bar == "injected bar"
73+
assert city == {"city": ["Boston", "Houston"]}
74+
assert numbers == [10,20,30]
7475
7576
"""
7677
)
7778
)
7879
result = pytester.runpytest()
79-
result.assert_outcomes(passed=1)
80+
result.assert_outcomes(passed=1)

0 commit comments

Comments
 (0)