Skip to content

Commit cfb6395

Browse files
betapl3bskhomuti
andauthored
Add @allure.manual decorator to simplify ALLURE_MANUAL=True label setting (allure-framework#688)
* Added a decorator to simplify ALLURE_MANUAL=True label usage. Added tests for "allure.manual" decorator * Add dynamic `manual` label Co-authored-by: skhomuti <skhomuti@gmail.com>
1 parent 78fc95f commit cfb6395

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Test manual label
2+
-------------
3+
4+
By default, ``ALLURE_MANUAL`` label is not set.
5+
6+
Usage of ``allure.manual`` decorator.
7+
8+
>>> import allure
9+
10+
11+
>>> @allure.manual
12+
... def test_manual():
13+
... pass
14+
15+
>>> def test_manual_dynamic():
16+
... allure.dynamic.manual()

allure-pytest/test/acceptance/label/manual/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from hamcrest import assert_that
2+
from allure_commons_test.report import has_test_case
3+
from allure_commons_test.label import has_label
4+
5+
6+
def test_allure_manual_label(executed_docstring_path):
7+
""" ./examples/label/manual/allure_manual.rst """
8+
assert_that(executed_docstring_path.allure_report,
9+
has_test_case("test_manual",
10+
has_label("ALLURE_MANUAL", True)
11+
)
12+
)
13+
14+
15+
def test_allure_manual_label_dynamic(executed_docstring_path):
16+
""" ./examples/label/manual/allure_manual.rst """
17+
assert_that(executed_docstring_path.allure_report,
18+
has_test_case("test_manual_dynamic",
19+
has_label("ALLURE_MANUAL", True)
20+
),
21+
)

allure-python-commons/allure.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from allure_commons._allure import Dynamic as dynamic
1111
from allure_commons._allure import step
1212
from allure_commons._allure import attach
13+
from allure_commons._allure import manual
1314
from allure_commons.types import Severity as severity_level
1415
from allure_commons.types import AttachmentType as attachment_type
1516

@@ -35,5 +36,6 @@
3536
'dynamic',
3637
'severity_level',
3738
'attach',
38-
'attachment_type'
39+
'attachment_type',
40+
'manual'
3941
]

allure-python-commons/src/_allure.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def id(id):
7070
return label(LabelType.ID, id)
7171

7272

73+
def manual(fn):
74+
return label(LabelType.MANUAL, True)(fn)
75+
76+
7377
def link(url, link_type=LinkType.LINK, name=None):
7478
return safely(plugin_manager.hook.decorate_as_link(url=url, link_type=link_type, name=name))
7579

@@ -140,6 +144,10 @@ def parent_suite(parent_suite_name):
140144
def sub_suite(sub_suite_name):
141145
Dynamic.label(LabelType.SUB_SUITE, sub_suite_name)
142146

147+
@staticmethod
148+
def manual():
149+
return Dynamic.label(LabelType.MANUAL, True)
150+
143151

144152
def step(title):
145153
if callable(title):
@@ -170,6 +178,7 @@ def impl(*a, **kw):
170178
args = list(map(lambda x: represent(x), a))
171179
with StepContext(self.title.format(*args, **params), params):
172180
return func(*a, **kw)
181+
173182
return impl
174183

175184

allure-python-commons/src/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class LabelType(str):
3131
ID = 'as_id'
3232
FRAMEWORK = 'framework'
3333
LANGUAGE = 'language'
34+
MANUAL = 'ALLURE_MANUAL'
3435

3536

3637
class AttachmentType(Enum):

0 commit comments

Comments
 (0)