Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions allure-behave/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,30 @@ def add_description_html(self, test_description_html):
if test_result:
test_result.descriptionHtml = test_description_html

@allure_commons.hookimpl
def add_preconditions(self, test_preconditions):
test_result = self.logger.get_test(None)
if test_result:
test_result.precondition = test_preconditions

@allure_commons.hookimpl
def add_preconditions_html(self, test_preconditions_html):
test_result = self.logger.get_test(None)
if test_result:
test_result.preconditionHtml = test_preconditions_html

@allure_commons.hookimpl
def add_expected_results(self, test_expected_results):
test_result = self.logger.get_test(None)
if test_result:
test_result.expectedResult = test_expected_results

@allure_commons.hookimpl
def add_expected_results_html(self, test_expected_results_html):
test_result = self.logger.get_test(None)
if test_result:
test_result.expectedResultHtml = test_expected_results_html

@allure_commons.hookimpl
def add_link(self, url, link_type, name):
test_result = self.logger.get_test(None)
Expand Down
44 changes: 44 additions & 0 deletions allure-pytest-bdd/src/allure_api_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

from .utils import ALLURE_DESCRIPTION_HTML_MARK
from .utils import ALLURE_DESCRIPTION_MARK
from .utils import ALLURE_PRECONDITIONS_MARK
from .utils import ALLURE_PRECONDITIONS_HTML_MARK
from .utils import ALLURE_EXPECTED_RESULTS_MARK
from .utils import ALLURE_EXPECTED_RESULTS_HTML_MARK
from .utils import ALLURE_LABEL_MARK
from .utils import ALLURE_LINK_MARK
from .utils import ALLURE_TITLE_ATTR
Expand Down Expand Up @@ -63,6 +67,26 @@ def add_description_html(self, test_description_html):
with self.lifecycle.update_test_case() as test_result:
test_result.descriptionHtml = test_description_html

@allure_commons.hookimpl
def decorate_as_preconditions(self, test_preconditions):
allure_preconditions = getattr(pytest.mark, ALLURE_PRECONDITIONS_MARK)
return allure_preconditions(test_preconditions)

@allure_commons.hookimpl
def decorate_as_preconditions_html(self, test_preconditions_html):
allure_preconditions_html = getattr(pytest.mark, ALLURE_PRECONDITIONS_HTML_MARK)
return allure_preconditions_html(test_preconditions_html)

@allure_commons.hookimpl
def decorate_as_expected_results(self, test_expected_results):
allure_expected_results = getattr(pytest.mark, ALLURE_EXPECTED_RESULTS_MARK)
return allure_expected_results(test_expected_results)

@allure_commons.hookimpl
def decorate_as_expected_results_html(self, test_expected_results_html):
allure_expected_results_html = getattr(pytest.mark, ALLURE_EXPECTED_RESULTS_HTML_MARK)
return allure_expected_results_html(test_expected_results_html)

@allure_commons.hookimpl
def decorate_as_label(self, label_type, labels):
allure_label_mark = getattr(pytest.mark, ALLURE_LABEL_MARK)
Expand All @@ -81,6 +105,26 @@ def decorate_as_link(self, url, link_type, name):
allure_link_mark = getattr(pytest.mark, ALLURE_LINK_MARK)
return allure_link_mark(url, name=name, link_type=link_type)

@allure_commons.hookimpl
def add_preconditions(self, test_preconditions):
with self.lifecycle.update_test_case() as test_result:
test_result.precondition = test_preconditions

@allure_commons.hookimpl
def add_preconditions_html(self, test_preconditions_html):
with self.lifecycle.update_test_case() as test_result:
test_result.preconditionHtml = test_preconditions_html

@allure_commons.hookimpl
def add_expected_results(self, test_expected_results):
with self.lifecycle.update_test_case() as test_result:
test_result.expectedResult = test_expected_results

@allure_commons.hookimpl
def add_expected_results_html(self, test_expected_results_html):
with self.lifecycle.update_test_case() as test_result:
test_result.expectedResultHtml = test_expected_results_html

@allure_commons.hookimpl
def add_link(self, url, link_type, name):
url = apply_link_pattern(self.__link_patterns, link_type, url)
Expand Down
12 changes: 10 additions & 2 deletions allure-pytest-bdd/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

from .utils import ALLURE_DESCRIPTION_MARK
from .utils import ALLURE_DESCRIPTION_HTML_MARK
from .utils import ALLURE_PRECONDITIONS_MARK
from .utils import ALLURE_PRECONDITIONS_HTML_MARK
from .utils import ALLURE_EXPECTED_RESULTS_MARK
from .utils import ALLURE_EXPECTED_RESULTS_HTML_MARK
from .utils import ALLURE_LABEL_MARK
from .utils import ALLURE_LINK_MARK

Expand Down Expand Up @@ -57,10 +61,14 @@ def clean_up():


def register_marks(config):
config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_MARK}: allure description")
config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_HTML_MARK}: allure description in HTML")
config.addinivalue_line("markers", f"{ALLURE_LABEL_MARK}: allure label marker")
config.addinivalue_line("markers", f"{ALLURE_LINK_MARK}: allure link marker")
config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_MARK}: allure description")
config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_HTML_MARK}: allure description in HTML")
config.addinivalue_line("markers", f"{ALLURE_PRECONDITIONS_MARK}: allure preconditions")
config.addinivalue_line("markers", f"{ALLURE_PRECONDITIONS_HTML_MARK}: allure preconditions html")
config.addinivalue_line("markers", f"{ALLURE_EXPECTED_RESULTS_MARK}: allure expected results")
config.addinivalue_line("markers", f"{ALLURE_EXPECTED_RESULTS_HTML_MARK}: allure expected results html")


def pytest_configure(config):
Expand Down
8 changes: 8 additions & 0 deletions allure-pytest-bdd/src/pytest_bdd_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from .storage import save_excinfo
from .storage import save_test_data
from .utils import attach_data
from .utils import get_allure_preconditions
from .utils import get_allure_preconditions_html
from .utils import get_allure_expected_results
from .utils import get_allure_expected_results_html
from .utils import get_allure_description
from .utils import get_allure_description_html
from .utils import get_allure_labels
Expand Down Expand Up @@ -67,6 +71,10 @@ def pytest_bdd_before_scenario(self, request, feature, scenario):
test_result.name = get_test_name(item, scenario, params)
test_result.description = get_allure_description(item, feature, scenario)
test_result.descriptionHtml = get_allure_description_html(item)
test_result.precondition = get_allure_preconditions(item)
test_result.preconditionHtml = get_allure_preconditions_html(item)
test_result.expectedResult = get_allure_expected_results(item)
test_result.expectedResultHtml = get_allure_expected_results_html(item)
test_result.start = now()
test_result.testCaseId = md5(full_name)
test_result.labels.append(Label(name=LabelType.HOST, value=self.host))
Expand Down
20 changes: 20 additions & 0 deletions allure-pytest-bdd/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
ALLURE_TITLE_ATTR = "__allure_display_name__"
ALLURE_DESCRIPTION_MARK = "allure_description"
ALLURE_DESCRIPTION_HTML_MARK = "allure_description_html"
ALLURE_PRECONDITIONS_MARK = "allure_preconditions"
ALLURE_PRECONDITIONS_HTML_MARK = "allure_preconditions_html"
ALLURE_EXPECTED_RESULTS_MARK = "allure_expected_results"
ALLURE_EXPECTED_RESULTS_HTML_MARK = "allure_expected_results_html"
ALLURE_LABEL_MARK = "allure_label"
ALLURE_LINK_MARK = "allure_link"

Expand Down Expand Up @@ -71,6 +75,22 @@ def get_allure_description_html(item):
return get_marker_value(item, ALLURE_DESCRIPTION_HTML_MARK)


def get_allure_preconditions(item):
return get_marker_value(item, ALLURE_PRECONDITIONS_MARK)


def get_allure_preconditions_html(item):
return get_marker_value(item, ALLURE_PRECONDITIONS_HTML_MARK)


def get_allure_expected_results(item):
return get_marker_value(item, ALLURE_EXPECTED_RESULTS_MARK)


def get_allure_expected_results_html(item):
return get_marker_value(item, ALLURE_EXPECTED_RESULTS_HTML_MARK)


def iter_all_labels(item):
for mark in item.iter_markers(name=ALLURE_LABEL_MARK):
name = mark.kwargs.get("label_type")
Expand Down
27 changes: 26 additions & 1 deletion allure-pytest/src/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import pytest
import allure_commons
from allure_pytest.utils import ALLURE_DESCRIPTION_MARK, ALLURE_DESCRIPTION_HTML_MARK
from allure_pytest.utils import ALLURE_DESCRIPTION_MARK
from allure_pytest.utils import ALLURE_DESCRIPTION_HTML_MARK
from allure_pytest.utils import ALLURE_PRECONDITIONS_MARK
from allure_pytest.utils import ALLURE_PRECONDITIONS_HTML_MARK
from allure_pytest.utils import ALLURE_EXPECTED_RESULTS_MARK
from allure_pytest.utils import ALLURE_EXPECTED_RESULTS_HTML_MARK
from allure_pytest.utils import ALLURE_LABEL_MARK, ALLURE_LINK_MARK
from allure_pytest.utils import format_allure_link

Expand Down Expand Up @@ -36,6 +41,26 @@ def decorate_as_description_html(self, test_description_html):
allure_description_html = getattr(pytest.mark, ALLURE_DESCRIPTION_HTML_MARK)
return allure_description_html(test_description_html)

@allure_commons.hookimpl
def decorate_as_preconditions(self, test_preconditions):
allure_preconditions = getattr(pytest.mark, ALLURE_PRECONDITIONS_MARK)
return allure_preconditions(test_preconditions)

@allure_commons.hookimpl
def decorate_as_preconditions_html(self, test_preconditions_html):
allure_preconditions_html = getattr(pytest.mark, ALLURE_PRECONDITIONS_HTML_MARK)
return allure_preconditions_html(test_preconditions_html)

@allure_commons.hookimpl
def decorate_as_expected_results(self, test_expected_results):
allure_expected_results = getattr(pytest.mark, ALLURE_EXPECTED_RESULTS_MARK)
return allure_expected_results(test_expected_results)

@allure_commons.hookimpl
def decorate_as_expected_results_html(self, test_expected_results_html):
allure_expected_results_html = getattr(pytest.mark, ALLURE_EXPECTED_RESULTS_HTML_MARK)
return allure_expected_results_html(test_expected_results_html)

@allure_commons.hookimpl
def decorate_as_label(self, label_type, labels):
allure_label = getattr(pytest.mark, ALLURE_LABEL_MARK)
Expand Down
32 changes: 32 additions & 0 deletions allure-pytest/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
from allure_commons.model2 import Label, Link
from allure_commons.model2 import Status
from allure_commons.types import LabelType, AttachmentType, ParameterMode
from allure_pytest.utils import allure_preconditions
from allure_pytest.utils import allure_preconditions_html
from allure_pytest.utils import allure_expected_results
from allure_pytest.utils import allure_expected_results_html
from allure_pytest.utils import allure_description, allure_description_html
from allure_pytest.utils import allure_labels, allure_links, pytest_markers
from allure_pytest.utils import allure_full_name, allure_package, allure_name
Expand Down Expand Up @@ -114,6 +118,10 @@ def pytest_runtest_setup(self, item):
test_result.testCaseId = md5(full_name)
test_result.description = allure_description(item)
test_result.descriptionHtml = allure_description_html(item)
test_result.precondition = allure_preconditions(item)
test_result.preconditionHtml = allure_preconditions_html(item)
test_result.expectedResult = allure_expected_results(item)
test_result.expectedResultHtml = allure_expected_results_html(item)
current_param_names = [param.name for param in test_result.parameters]
test_result.parameters.extend([
Parameter(name=name, value=represent(value))
Expand Down Expand Up @@ -299,6 +307,30 @@ def add_description_html(self, test_description_html):
if test_result:
test_result.descriptionHtml = test_description_html

@allure_commons.hookimpl
def add_preconditions(self, test_preconditions):
test_result = self.allure_logger.get_test(None)
if test_result:
test_result.precondition = test_preconditions

@allure_commons.hookimpl
def add_preconditions_html(self, test_preconditions_html):
test_result = self.allure_logger.get_test(None)
if test_result:
test_result.preconditionHtml = test_preconditions_html

@allure_commons.hookimpl
def add_expected_results(self, test_expected_results):
test_result = self.allure_logger.get_test(None)
if test_result:
test_result.expectedResult = test_expected_results

@allure_commons.hookimpl
def add_expected_results_html(self, test_expected_results_html):
test_result = self.allure_logger.get_test(None)
if test_result:
test_result.expectedResultHtml = test_expected_results_html

@allure_commons.hookimpl
def add_link(self, url, link_type, name):
test_result = self.allure_logger.get_test(None)
Expand Down
14 changes: 12 additions & 2 deletions allure-pytest/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
from allure_pytest.helper import AllureTestHelper, AllureTitleHelper
from allure_pytest.listener import AllureListener

from allure_pytest.utils import ALLURE_DESCRIPTION_MARK, ALLURE_DESCRIPTION_HTML_MARK
from allure_pytest.utils import ALLURE_LABEL_MARK, ALLURE_LINK_MARK
from allure_pytest.utils import ALLURE_DESCRIPTION_MARK
from allure_pytest.utils import ALLURE_DESCRIPTION_HTML_MARK
from allure_pytest.utils import ALLURE_PRECONDITIONS_MARK
from allure_pytest.utils import ALLURE_PRECONDITIONS_HTML_MARK
from allure_pytest.utils import ALLURE_EXPECTED_RESULTS_MARK
from allure_pytest.utils import ALLURE_EXPECTED_RESULTS_HTML_MARK
from allure_pytest.utils import ALLURE_LABEL_MARK
from allure_pytest.utils import ALLURE_LINK_MARK


def pytest_addoption(parser):
Expand Down Expand Up @@ -172,6 +178,10 @@ def pytest_configure(config):
config.addinivalue_line("markers", f"{ALLURE_LINK_MARK}: allure link marker")
config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_MARK}: allure description")
config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_HTML_MARK}: allure description html")
config.addinivalue_line("markers", f"{ALLURE_PRECONDITIONS_MARK}: allure preconditions")
config.addinivalue_line("markers", f"{ALLURE_PRECONDITIONS_HTML_MARK}: allure preconditions html")
config.addinivalue_line("markers", f"{ALLURE_EXPECTED_RESULTS_MARK}: allure expected results")
config.addinivalue_line("markers", f"{ALLURE_EXPECTED_RESULTS_HTML_MARK}: allure expected results html")


def select_by_labels(items, config):
Expand Down
20 changes: 20 additions & 0 deletions allure-pytest/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

ALLURE_DESCRIPTION_MARK = "allure_description"
ALLURE_DESCRIPTION_HTML_MARK = "allure_description_html"
ALLURE_PRECONDITIONS_MARK = "allure_preconditions"
ALLURE_PRECONDITIONS_HTML_MARK = "allure_preconditions_html"
ALLURE_EXPECTED_RESULTS_MARK = "allure_expected_results"
ALLURE_EXPECTED_RESULTS_HTML_MARK = "allure_expected_results_html"
ALLURE_LABEL_MARK = "allure_label"
ALLURE_LINK_MARK = "allure_link"
ALLURE_UNIQUE_LABELS = [
Expand Down Expand Up @@ -73,6 +77,22 @@ def allure_description_html(item):
return get_marker_value(item, ALLURE_DESCRIPTION_HTML_MARK)


def allure_preconditions(item):
return get_marker_value(item, ALLURE_PRECONDITIONS_MARK)


def allure_preconditions_html(item):
return get_marker_value(item, ALLURE_PRECONDITIONS_HTML_MARK)


def allure_expected_results(item):
return get_marker_value(item, ALLURE_EXPECTED_RESULTS_MARK)


def allure_expected_results_html(item):
return get_marker_value(item, ALLURE_EXPECTED_RESULTS_HTML_MARK)


def allure_label(item, label):
labels = []
for mark in item.iter_markers(name=ALLURE_LABEL_MARK):
Expand Down
16 changes: 16 additions & 0 deletions allure-python-commons-test/src/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ def has_description_html(*matchers):
return has_entry("descriptionHtml", all_of(*matchers))


def has_preconditions(*matchers):
return has_entry("precondition", all_of(*matchers))


def has_preconditions_html(*matchers):
return has_entry("preconditionHtml", all_of(*matchers))


def has_expected_results(*matchers):
return has_entry("expectedResult", all_of(*matchers))


def has_expected_results_html(*matchers):
return has_entry("expectedResultHtml", all_of(*matchers))


def has_step(name, *matchers):
return has_entry(
"steps",
Expand Down
8 changes: 8 additions & 0 deletions allure-python-commons/src/allure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from allure_commons._allure import title
from allure_commons._allure import description, description_html
from allure_commons._allure import preconditions
from allure_commons._allure import preconditions_html
from allure_commons._allure import expected_results
from allure_commons._allure import expected_results_html
from allure_commons._allure import label
from allure_commons._allure import severity
from allure_commons._allure import tag
Expand All @@ -23,6 +27,10 @@
"title",
"description",
"description_html",
"preconditions",
"preconditions_html",
"expected_results",
"expected_results_html",
"label",
"severity",
"suite",
Expand Down
Loading
Loading