From bf898441df5c6ed8c3cf22511325952cb4cbb69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D1=84=D0=B8=D0=BD=20=D0=90=D0=BB=D1=8C=D0=B1?= =?UTF-8?q?=D0=B5=D1=80=D1=82=20=D0=90=D0=B4=D0=B8=D0=BB=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Mon, 26 Sep 2022 12:36:25 +0300 Subject: [PATCH 1/6] Added a decorator to simplify ALLURE_MANUAL=True label usage. Added tests for "allure.manual" decorator --- .../examples/label/manual/allure_manual.rst | 20 ++++++++++++++++++ .../test/acceptance/label/manual/__init__.py | 0 .../acceptance/label/manual/manual_test.py | 21 +++++++++++++++++++ allure-python-commons/allure.py | 4 +++- allure-python-commons/src/_allure.py | 3 +++ allure-python-commons/src/types.py | 1 + 6 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 allure-pytest/examples/label/manual/allure_manual.rst create mode 100644 allure-pytest/test/acceptance/label/manual/__init__.py create mode 100644 allure-pytest/test/acceptance/label/manual/manual_test.py diff --git a/allure-pytest/examples/label/manual/allure_manual.rst b/allure-pytest/examples/label/manual/allure_manual.rst new file mode 100644 index 00000000..203a0f39 --- /dev/null +++ b/allure-pytest/examples/label/manual/allure_manual.rst @@ -0,0 +1,20 @@ +Test manual label +------------- + +By default, ``ALLURE_MANUAL`` label is not set. + +Usage of ``allure.manual`` decorator with out arguments (``True`` by default) + + >>> import allure + + + >>> @allure.manual() + ... def test_manual(): + ... pass + + +``False`` can be set just in case. + + >>> @allure.manual(False) + ... def test_manual_false(): + ... pass \ No newline at end of file diff --git a/allure-pytest/test/acceptance/label/manual/__init__.py b/allure-pytest/test/acceptance/label/manual/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/allure-pytest/test/acceptance/label/manual/manual_test.py b/allure-pytest/test/acceptance/label/manual/manual_test.py new file mode 100644 index 00000000..8a8626b4 --- /dev/null +++ b/allure-pytest/test/acceptance/label/manual/manual_test.py @@ -0,0 +1,21 @@ +""" ./examples/label/manual/allure_manual.rst """ + +from hamcrest import assert_that +from allure_commons_test.report import has_test_case +from allure_commons_test.label import has_label + + +def test_allure_manual_label(executed_docstring_path): + assert_that(executed_docstring_path.allure_report, + has_test_case("test_manual", + has_label("ALLURE_MANUAL", True) + ) + ) + + +def test_allure_manual_false_label(executed_docstring_path): + assert_that(executed_docstring_path.allure_report, + has_test_case("test_manual_false", + has_label("ALLURE_MANUAL", False) + ) + ) diff --git a/allure-python-commons/allure.py b/allure-python-commons/allure.py index 9d6c99f0..58f2891f 100644 --- a/allure-python-commons/allure.py +++ b/allure-python-commons/allure.py @@ -10,6 +10,7 @@ from allure_commons._allure import Dynamic as dynamic from allure_commons._allure import step from allure_commons._allure import attach +from allure_commons._allure import manual from allure_commons.types import Severity as severity_level from allure_commons.types import AttachmentType as attachment_type @@ -35,5 +36,6 @@ 'dynamic', 'severity_level', 'attach', - 'attachment_type' + 'attachment_type', + 'manual' ] diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index 565ac955..899f6723 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -69,6 +69,9 @@ def tag(*tags): def id(id): return label(LabelType.ID, id) +def manual(is_manual=True): + return label(LabelType.MANUAL, is_manual) + def link(url, link_type=LinkType.LINK, name=None): return safely(plugin_manager.hook.decorate_as_link(url=url, link_type=link_type, name=name)) diff --git a/allure-python-commons/src/types.py b/allure-python-commons/src/types.py index d2fef791..321a7f0c 100644 --- a/allure-python-commons/src/types.py +++ b/allure-python-commons/src/types.py @@ -31,6 +31,7 @@ class LabelType(str): ID = 'as_id' FRAMEWORK = 'framework' LANGUAGE = 'language' + MANUAL = 'ALLURE_MANUAL' class AttachmentType(Enum): From 6d6000cd2d7f6dcd4fb666927f908a232c5d1501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D1=84=D0=B8=D0=BD=20=D0=90=D0=BB=D1=8C=D0=B1?= =?UTF-8?q?=D0=B5=D1=80=D1=82=20=D0=90=D0=B4=D0=B8=D0=BB=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Mon, 26 Sep 2022 12:44:31 +0300 Subject: [PATCH 2/6] Fixed E302 blank lines --- allure-python-commons/src/_allure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index 899f6723..a97b6811 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -69,6 +69,7 @@ def tag(*tags): def id(id): return label(LabelType.ID, id) + def manual(is_manual=True): return label(LabelType.MANUAL, is_manual) From 4b075f89a34bae32cee835d2c39e230e8e958c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D1=84=D0=B8=D0=BD=20=D0=90=D0=BB=D1=8C=D0=B1?= =?UTF-8?q?=D0=B5=D1=80=D1=82=20=D0=90=D0=B4=D0=B8=D0=BB=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Wed, 28 Sep 2022 11:28:08 +0300 Subject: [PATCH 3/6] removed is_manual argument from manual decorator --- allure-pytest/examples/label/manual/allure_manual.rst | 11 ++--------- .../test/acceptance/label/manual/manual_test.py | 8 -------- allure-python-commons/src/_allure.py | 4 ++-- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/allure-pytest/examples/label/manual/allure_manual.rst b/allure-pytest/examples/label/manual/allure_manual.rst index 203a0f39..59be592f 100644 --- a/allure-pytest/examples/label/manual/allure_manual.rst +++ b/allure-pytest/examples/label/manual/allure_manual.rst @@ -3,18 +3,11 @@ Test manual label By default, ``ALLURE_MANUAL`` label is not set. -Usage of ``allure.manual`` decorator with out arguments (``True`` by default) +Usage of ``allure.manual`` decorator. >>> import allure - >>> @allure.manual() + >>> @allure.manual ... def test_manual(): ... pass - - -``False`` can be set just in case. - - >>> @allure.manual(False) - ... def test_manual_false(): - ... pass \ No newline at end of file diff --git a/allure-pytest/test/acceptance/label/manual/manual_test.py b/allure-pytest/test/acceptance/label/manual/manual_test.py index 8a8626b4..813dff6b 100644 --- a/allure-pytest/test/acceptance/label/manual/manual_test.py +++ b/allure-pytest/test/acceptance/label/manual/manual_test.py @@ -11,11 +11,3 @@ def test_allure_manual_label(executed_docstring_path): has_label("ALLURE_MANUAL", True) ) ) - - -def test_allure_manual_false_label(executed_docstring_path): - assert_that(executed_docstring_path.allure_report, - has_test_case("test_manual_false", - has_label("ALLURE_MANUAL", False) - ) - ) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index a97b6811..c6d2f07e 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -70,8 +70,8 @@ def id(id): return label(LabelType.ID, id) -def manual(is_manual=True): - return label(LabelType.MANUAL, is_manual) +def manual(): + return label(LabelType.MANUAL, True) def link(url, link_type=LinkType.LINK, name=None): From f126e0062f984e14d187c144f8715ec32a932610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D1=84=D0=B8=D0=BD=20=D0=90=D0=BB=D1=8C=D0=B1?= =?UTF-8?q?=D0=B5=D1=80=D1=82=20=D0=90=D0=B4=D0=B8=D0=BB=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Wed, 28 Sep 2022 12:40:41 +0300 Subject: [PATCH 4/6] `allure.manual` function replaced with decorator using `Dynamic.label` --- allure-pytest/test/acceptance/label/manual/manual_test.py | 3 +-- allure-python-commons/src/_allure.py | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/allure-pytest/test/acceptance/label/manual/manual_test.py b/allure-pytest/test/acceptance/label/manual/manual_test.py index 813dff6b..77c3220e 100644 --- a/allure-pytest/test/acceptance/label/manual/manual_test.py +++ b/allure-pytest/test/acceptance/label/manual/manual_test.py @@ -1,11 +1,10 @@ -""" ./examples/label/manual/allure_manual.rst """ - from hamcrest import assert_that from allure_commons_test.report import has_test_case from allure_commons_test.label import has_label def test_allure_manual_label(executed_docstring_path): + """ ./examples/label/manual/allure_manual.rst """ assert_that(executed_docstring_path.allure_report, has_test_case("test_manual", has_label("ALLURE_MANUAL", True) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index c6d2f07e..0158f489 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -70,8 +70,11 @@ def id(id): return label(LabelType.ID, id) -def manual(): - return label(LabelType.MANUAL, True) +def manual(fn): + def inner(): + return Dynamic.label(LabelType.MANUAL, True) + + return inner def link(url, link_type=LinkType.LINK, name=None): @@ -174,6 +177,7 @@ def impl(*a, **kw): args = list(map(lambda x: represent(x), a)) with StepContext(self.title.format(*args, **params), params): return func(*a, **kw) + return impl From af8cdc6101375bc147d453636dad07e5d1728934 Mon Sep 17 00:00:00 2001 From: skhomuti Date: Wed, 5 Oct 2022 22:18:03 +0400 Subject: [PATCH 5/6] Make manual non-callable --- allure-python-commons/src/_allure.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index 0158f489..5d047f7c 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -71,10 +71,7 @@ def id(id): def manual(fn): - def inner(): - return Dynamic.label(LabelType.MANUAL, True) - - return inner + return label(LabelType.MANUAL, True)(fn) def link(url, link_type=LinkType.LINK, name=None): From 39bd4d3c2451c6701ab16e6351629185d07f1538 Mon Sep 17 00:00:00 2001 From: skhomuti Date: Wed, 5 Oct 2022 22:27:10 +0400 Subject: [PATCH 6/6] Add dynamic `manual` label --- allure-pytest/examples/label/manual/allure_manual.rst | 3 +++ .../test/acceptance/label/manual/manual_test.py | 9 +++++++++ allure-python-commons/src/_allure.py | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/allure-pytest/examples/label/manual/allure_manual.rst b/allure-pytest/examples/label/manual/allure_manual.rst index 59be592f..c189d710 100644 --- a/allure-pytest/examples/label/manual/allure_manual.rst +++ b/allure-pytest/examples/label/manual/allure_manual.rst @@ -11,3 +11,6 @@ Usage of ``allure.manual`` decorator. >>> @allure.manual ... def test_manual(): ... pass + + >>> def test_manual_dynamic(): + ... allure.dynamic.manual() diff --git a/allure-pytest/test/acceptance/label/manual/manual_test.py b/allure-pytest/test/acceptance/label/manual/manual_test.py index 77c3220e..a04a315b 100644 --- a/allure-pytest/test/acceptance/label/manual/manual_test.py +++ b/allure-pytest/test/acceptance/label/manual/manual_test.py @@ -10,3 +10,12 @@ def test_allure_manual_label(executed_docstring_path): has_label("ALLURE_MANUAL", True) ) ) + + +def test_allure_manual_label_dynamic(executed_docstring_path): + """ ./examples/label/manual/allure_manual.rst """ + assert_that(executed_docstring_path.allure_report, + has_test_case("test_manual_dynamic", + has_label("ALLURE_MANUAL", True) + ), + ) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index 5d047f7c..32025c47 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -144,6 +144,10 @@ def parent_suite(parent_suite_name): def sub_suite(sub_suite_name): Dynamic.label(LabelType.SUB_SUITE, sub_suite_name) + @staticmethod + def manual(): + return Dynamic.label(LabelType.MANUAL, True) + def step(title): if callable(title):