Skip to content

Commit ddf8121

Browse files
authored
parametrize with metafunc (fixes #37 via #38)
1 parent 6e17233 commit ddf8121

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

allure-pytest/test/metafunc/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
def pytest_generate_tests(metafunc):
3+
4+
if 'metafunc_param' in metafunc.fixturenames:
5+
metafunc.parametrize("metafunc_param", [True])
6+
elif 'metafunc_param_with_ids' in metafunc.fixturenames:
7+
metafunc.parametrize("metafunc_param_with_ids", [True], ids=['metafunc_param_id'])
8+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
>>> allure_report = getfixture('allure_report')
3+
4+
>>> assert_that(allure_report,
5+
... all_of(
6+
... has_property('test_cases', has_length(2)),
7+
... has_property('test_groups', has_length(0))
8+
... ))
9+
"""
10+
11+
12+
def test_metafunc_param(metafunc_param):
13+
"""
14+
>>> allure_report = getfixture('allure_report')
15+
>>> assert_that(allure_report,
16+
... has_test_case('test_metafunc_param[True]',
17+
... has_parameter('metafunc_param', True)
18+
... )
19+
... )
20+
"""
21+
assert metafunc_param
22+
23+
24+
def test_metafunc_param_with_ids(metafunc_param_with_ids):
25+
"""
26+
>>> allure_report = getfixture('allure_report')
27+
28+
>>> assert_that(allure_report,
29+
... has_test_case('test_metafunc_param_with_ids[metafunc_param_id]',
30+
... has_parameter('metafunc_param_id', True)
31+
... )
32+
... ) # doctest: +SKIP
33+
34+
>>> assert_that(allure_report,
35+
... has_test_case('test_metafunc_param_with_ids[metafunc_param_id]',
36+
... has_parameter('metafunc_param_with_ids', True)
37+
... )
38+
... )
39+
"""
40+
assert metafunc_param_with_ids

0 commit comments

Comments
 (0)