22import 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 (
99 """\
1010 Feature: Given
1111 Scenario: Test given fixture injection
12- Given I have injecting given
12+ Given I have injected single value
1313 Then foo should be "injected foo"
14+ Given I have injected tuple value
15+ Then foo should be tuple value
1416 """
1517 ),
1618 )
@@ -24,31 +26,37 @@ def test_given_injection(pytester):
2426 def test_given():
2527 pass
2628
27- @given("I have injecting given ", target_fixture="foo")
29+ @given("I have injected single value ", target_fixture="foo")
2830 def _():
2931 return "injected foo"
3032
33+ @given("I have injected tuple value", target_fixture="foo")
34+ def _():
35+ return ("injected foo", {"city": ["Boston", "Houston"]}, [10,20,30],)
3136
3237 @then('foo should be "injected foo"')
3338 def _(foo):
3439 assert foo == "injected foo"
3540
41+ @then('foo should be tuple value')
42+ def _(foo):
43+ assert foo == ("injected foo", {"city": ["Boston", "Houston"]}, [10,20,30],)
3644 """
3745 )
3846 )
3947 result = pytester .runpytest ()
4048 result .assert_outcomes (passed = 1 )
4149
4250
43- def test_given_injection_multiple (pytester ):
51+ def test_given_injection_multiple_values (pytester ):
4452 pytester .makefile (
4553 ".feature" ,
4654 given = textwrap .dedent (
4755 """\
4856 Feature: Given
4957 Scenario: Test given fixture injection
50- Given I have injecting given
51- Then foo should be "injected foo"
58+ Given I have injecting given values
59+ Then values should be received
5260 """
5361 ),
5462 )
@@ -62,18 +70,19 @@ def test_given_injection_multiple(pytester):
6270 def test_given():
6371 pass
6472
65- @given("I have injecting given", target_fixture="foo,bar ")
73+ @given("I have injecting given values ", target_fixture="foo,city,numbers ")
6674 def _():
67- return "injected foo", "injected bar"
75+ return ( "injected foo", {"city": ["Boston", "Houston"]}, [10,20,30],)
6876
6977
70- @then('foo should be "injected foo"' )
71- def _(foo, bar ):
78+ @then("values should be received" )
79+ def _(foo, city, numbers ):
7280 assert foo == "injected foo"
73- assert bar == "injected bar"
81+ assert city == {"city": ["Boston", "Houston"]}
82+ assert numbers == [10,20,30]
7483
7584 """
7685 )
7786 )
7887 result = pytester .runpytest ()
79- result .assert_outcomes (passed = 1 )
88+ result .assert_outcomes (passed = 1 )
0 commit comments