Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user/tests to delete (and hence not just append but modify) any label that is available #600

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions allure-pytest/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ def add_label(self, label_type, labels):
for label in labels if test_result else ():
test_result.labels.append(Label(label_type, label))

@allure_commons.hookimpl
def remove_label(self, label_types):
test_result = self.allure_logger.get_test(None)
if test_result:
labels_to_keep = list()
for labels_in_test in test_result.labels:
if labels_in_test.name not in label_types:
labels_to_keep.append(labels_in_test)
test_result.labels = labels_to_keep

class ItemCache(object):

Expand Down
8 changes: 8 additions & 0 deletions allure-python-commons/src/_allure.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def description_html(test_description_html):
def label(label_type, *labels):
plugin_manager.hook.add_label(label_type=label_type, labels=labels)

@staticmethod
def del_label(*label_types):
plugin_manager.hook.remove_label(label_types=label_types)

@staticmethod
def severity(severity_level):
Dynamic.label(LabelType.SEVERITY, severity_level)
Expand All @@ -108,6 +112,10 @@ def severity(severity_level):
def feature(*features):
Dynamic.label(LabelType.FEATURE, *features)

@staticmethod
def remove_feature():
Dynamic.del_label(LabelType.FEATURE)

@staticmethod
def story(*stories):
Dynamic.label(LabelType.STORY, *stories)
Expand Down
4 changes: 4 additions & 0 deletions allure-python-commons/src/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def decorate_as_label(self, label_type, labels):
def add_label(self, label_type, labels):
""" label """

@hookspec
def remove_label(self, label_type, labels):
""" label """

@hookspec
def decorate_as_link(self, url, link_type, name):
""" url """
Expand Down