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

ISSUE#616: Stringify labels #617

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
21 changes: 20 additions & 1 deletion allure-pytest/test/acceptance/label/bdd/bdd_label_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" ./examples/label/bdd/bdd_label.rst """
import json

from hamcrest import assert_that
from hamcrest import assert_that, calling, is_not, raises
from allure_commons_test.report import has_test_case
from allure_commons_test.label import has_epic
from allure_commons_test.label import has_feature
Expand Down Expand Up @@ -29,3 +30,21 @@ def test_multiple_bdd_label(executed_docstring_path):
has_story("Alternative story")
)
)


def test_set_bdd_label_as_object(executed_docstring_source):
"""
>>> import allure

>>> class SomeClass:
... pass

>>> @allure.feature(SomeClass())
... def test_set_label_as_object_example():
... allure.dynamic.feature(SomeClass)
"""

assert_that(
calling(json.dumps).with_args(executed_docstring_source.allure_report.test_cases),
is_not(raises(TypeError, 'not JSON serializable'))
)
4 changes: 2 additions & 2 deletions allure-python-commons/src/_allure.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def epic(*epics):


def feature(*features):
return label(LabelType.FEATURE, *features)
return label(LabelType.FEATURE, *[str(feature) for feature in features])


def story(*stories):
Expand Down Expand Up @@ -103,7 +103,7 @@ def severity(severity_level):

@staticmethod
def feature(*features):
Dynamic.label(LabelType.FEATURE, *features)
Dynamic.label(LabelType.FEATURE, *[str(feature) for feature in features])

@staticmethod
def story(*stories):
Expand Down