Skip to content

Commit c5379d5

Browse files
committed
Added a test corresponding to #17
1 parent 02d167a commit c5379d5

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# META
2+
# {'passed': 8, 'skipped': 5, 'failed': 1}
3+
# END META
4+
5+
# This is the example in https://github.com/smarie/python-pytest-steps/issues/17
6+
import pytest
7+
from pytest_steps import test_steps
8+
9+
10+
@pytest.fixture(scope='module')
11+
def results_dct():
12+
return dict()
13+
14+
15+
@test_steps('step1', 'step2')
16+
def test_1_2(results_dct):
17+
# step 1
18+
results_dct['step1'] = 1
19+
yield
20+
# step 2
21+
results_dct['step2'] = 'hello'
22+
yield
23+
24+
25+
@test_steps('step3', 'step4')
26+
@pytest.mark.parametrize('p', ['a', 'b'], ids="p={}".format)
27+
def test_3_4(p, results_dct):
28+
if 'step2' not in results_dct:
29+
pytest.skip("Can not start step 3: step 2 has not run successfuly")
30+
# step 3
31+
results_dct.setdefault('step3', dict())[p] = 'bla'
32+
if p == 'b':
33+
assert False
34+
yield
35+
# step 4
36+
results_dct.setdefault('step4', dict())[p] = 'blabla'
37+
yield
38+
39+
40+
@test_steps('step5', 'step6')
41+
@pytest.mark.parametrize('q', ['a', 'b'], ids="q={}".format)
42+
@pytest.mark.parametrize('p', ['a', 'b'], ids="p={}".format)
43+
def test_5_6(p, q, results_dct):
44+
if 'step4' not in results_dct:
45+
pytest.skip("Can not start step 5: step 4 has not run successfuly")
46+
elif p not in results_dct['step4']:
47+
pytest.skip("Can not start step 5: step 4 has not run successfuly for this value of p=%s" % p)
48+
# step 5
49+
yield
50+
# step 6
51+
yield

0 commit comments

Comments
 (0)