Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and arunpkm committed Apr 21, 2023
1 parent 0959385 commit c9d451b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/pytest_bdd/scenario.py
Expand Up @@ -162,9 +162,11 @@ def _execute_step_function(
raise

if context.target_fixture is not None:
target_fixture_tokens = [token for token in context.target_fixture.split(',') if token]
target_fixture_tokens = [token for token in context.target_fixture.split(",") if token]
return_values = (return_value,) if not isinstance(return_value, tuple) else return_value
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)}"
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)}"
for token, value in zip(target_fixture_tokens, return_values):
inject_fixture(request, token, value)

Expand Down
21 changes: 11 additions & 10 deletions tests/steps/test_given.py
Expand Up @@ -2,7 +2,7 @@
import textwrap


def test_given_injection(pytester):
def test_given_injection_single_value(pytester):
pytester.makefile(
".feature",
given=textwrap.dedent(
Expand Down Expand Up @@ -40,15 +40,15 @@ def _(foo):
result.assert_outcomes(passed=1)


def test_given_injection_multiple(pytester):
def test_given_injection_multiple_values(pytester):
pytester.makefile(
".feature",
given=textwrap.dedent(
"""\
Feature: Given
Scenario: Test given fixture injection
Given I have injecting given
Then foo should be "injected foo"
Given I have injecting given values
Then values should be received
"""
),
)
Expand All @@ -62,18 +62,19 @@ def test_given_injection_multiple(pytester):
def test_given():
pass
@given("I have injecting given", target_fixture="foo,bar")
@given("I have injecting given values", target_fixture="foo,city,numbers")
def _():
return "injected foo", "injected bar"
return ("injected foo", {"city": ["Boston", "Houston"]}, [10,20,30],)
@then('foo should be "injected foo"')
def _(foo, bar):
@then("values should be received")
def _(foo, city, numbers):
assert foo == "injected foo"
assert bar == "injected bar"
assert city == {"city": ["Boston", "Houston"]}
assert numbers == [10,20,30]
"""
)
)
result = pytester.runpytest()
result.assert_outcomes(passed=1)
result.assert_outcomes(passed=1)

0 comments on commit c9d451b

Please sign in to comment.