Skip to content

Commit 0ff5619

Browse files
authored
add placeholders in step's title feature (fixes #47 via #52)
* add placeholders in step's title feature * . * fix comment in tox.ini
1 parent 7f69719 commit 0ff5619

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

allure-pytest/src/allure/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __call__(self, func):
9999
def impl(*a, **kw):
100100
__tracebackhide__ = True
101101
params = step_parameters(func, *a, **kw)
102-
with StepContext(self.allure, self.title, params):
102+
with StepContext(self.allure, self.title.format(*a, **kw), params):
103103
return func(*a, **kw)
104104
return impl
105105

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""
2+
>>> allure_report = getfixture('allure_report')
3+
4+
>>> assert_that(allure_report,
5+
... all_of(
6+
... has_property('test_cases', has_length(6)),
7+
... has_property('test_groups', has_length(0))
8+
... )) # doctest: +SKIP
9+
"""
10+
11+
import pytest
12+
13+
14+
@pytest.allure.step('arg is {0}')
15+
def step_with_equal_args(step_arg_param):
16+
assert step_arg_param
17+
18+
19+
def test_equal_args_and_places():
20+
"""
21+
>>> allure_report = getfixture('allure_report')
22+
>>> assert_that(allure_report,
23+
... has_test_case('test_equal_args_and_places',
24+
... has_step('arg is {0}'.format(True),
25+
... has_parameter('step_arg_param', True)
26+
... )
27+
... )
28+
... )
29+
"""
30+
step_with_equal_args(True)
31+
32+
33+
@pytest.allure.step('arg is {0}')
34+
def step_places_less(step_arg_param1, step_arg_param2):
35+
assert step_arg_param1 and step_arg_param2
36+
37+
38+
def test_places_less():
39+
"""
40+
>>> allure_report = getfixture('allure_report')
41+
>>> assert_that(allure_report,
42+
... has_test_case('test_places_less',
43+
... has_step('arg is {0}'.format(True, True),
44+
... has_parameter('step_arg_param1', True),
45+
... has_parameter('step_arg_param2', True)
46+
... )
47+
... )
48+
... )
49+
"""
50+
step_places_less(True, True)
51+
52+
53+
@pytest.allure.step('arg are {0} and {1}')
54+
def step_args_less(step_arg_param,):
55+
assert step_arg_param
56+
57+
58+
def test_args_less():
59+
"""
60+
>>> allure_report = getfixture('allure_report')
61+
>>> assert_that(allure_report,
62+
... has_test_case('test_args_less',
63+
... has_status_details(
64+
... with_status_message('IndexError: tuple index out of range')
65+
... )
66+
... )
67+
... )
68+
"""
69+
step_args_less(True)

allure-pytest/tox.ini

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@ deps=
1414
commands=
1515
python setup.py develop
1616
rm -f {envtmpdir}/*.json
17-
py.test --doctest-module --alluredir={envtmpdir} ./test/
17+
py.test --doctest-module --alluredir={envtmpdir} {posargs: ./test/}
1818

1919

20+
# Run tests without result checking. It is useful for:
21+
# 1. Getting demo report: `tox -e demo`
22+
# 2. Executing separate test:
23+
# `tox -e demo -- -k test_single_feature_label` or
24+
# `tox -e demo -- ./test/steps/`
2025
[testenv:demo]
2126
whitelist_externals = rm
2227

28+
setenv =
29+
ALLURE_INDENT_OUTPUT=yep
30+
2331
commands=
2432
python setup.py develop
2533
rm -f {envtmpdir}/*.json
26-
- py.test --alluredir={envtmpdir} ./test/
34+
- py.test -v --alluredir={envtmpdir} {posargs: ./test/}
35+
2736

2837
[testenv:static_check]
2938
deps=

0 commit comments

Comments
 (0)