-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathtest_parametrized.py
More file actions
58 lines (43 loc) · 1.34 KB
/
test_parametrized.py
File metadata and controls
58 lines (43 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pytest
from pytest_bdd import given, when, then, scenario
@pytest.mark.parametrize(
['start', 'eat', 'left'],
[(12, 5, 7)])
@scenario(
'parametrized.feature',
'Parametrized given, when, thens',
)
def test_parametrized(request, start, eat, left):
"""Test parametrized scenario."""
@pytest.mark.parametrize(
'start', [12]
)
@scenario(
'parametrized.feature',
'Parametrized given - single param',
)
def test_parametrized_single_param(request, start):
"""Test parametrized scenario."""
@pytest.fixture(params=[1, 2])
def foo_bar(request):
return 'bar' * request.param
@pytest.mark.parametrize(
['start', 'eat', 'left'],
[(12, 5, 7)])
@scenario(
'parametrized.feature',
'Parametrized given, when, thens',
)
def test_parametrized_with_other_fixtures(request, start, eat, left, foo_bar):
"""Test parametrized scenario, but also with other parametrized fixtures."""
@given('there are <start> cucumbers')
def start_cucumbers(start):
return dict(start=start)
@when('I eat <eat> cucumbers')
def eat_cucumbers(start_cucumbers, start, eat):
start_cucumbers['eat'] = eat
@then('I should have <left> cucumbers')
def should_have_left_cucumbers(start_cucumbers, start, eat, left):
assert start - eat == left
assert start_cucumbers['start'] == start
assert start_cucumbers['eat'] == eat