Skip to content

Commit ae33c32

Browse files
authored
Adds support to have attributes with same keys
1 parent b5df19e commit ae33c32

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pytest_reportportal/service.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,15 @@ def get_marker_value(item, keyword):
660660
for k in item.keywords:
661661
if get_marker(k) is not None and k not in self.ignored_attributes:
662662
raw_attrs.extend(get_marker_value(item, k))
663+
# When we have custom markers with different values, append the
664+
# raw_attrs with the markers which were missed initially.
665+
# Adds supports to have two attributes with same keys.
666+
for cust_marker in item.own_markers:
667+
for arg in cust_marker.args:
668+
custom_arg = "{0}:{1}".format(cust_marker.name, arg)
669+
if not (custom_arg in raw_attrs) and \
670+
cust_marker.name not in self.ignored_attributes:
671+
raw_attrs.append(custom_arg)
663672
raw_attrs.extend(item.session.config.getini('rp_tests_attributes'))
664673
return gen_attributes(raw_attrs)
665674

tests/test_service.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def __iter__(self):
3737
mocked_item.session.config.getini = getini
3838
mocked_item.keywords = NodeKeywords()
3939
mocked_item.get_closest_marker = get_closest_marker
40+
mocked_item.own_markers = [
41+
pytest.mark.test_decorator_key('test_decorator_value'),
42+
pytest.mark.test_decorator_key('new_decorator_value'),
43+
]
4044
markers = rp_service._get_item_markers(mocked_item)
4145
assert markers == [{'value': 'test_marker'},
4246
{'key': 'test_decorator_key',
@@ -45,6 +49,8 @@ def __iter__(self):
4549
'value': 'test_value1'},
4650
{'key': 'test_decorator_key_with_multi_value',
4751
'value': 'test_value2'},
52+
{'key': 'test_decorator_key',
53+
'value': 'new_decorator_value'},
4854
{'value': 'ini_marker'},
4955
{'key': 'test_ini_key',
5056
'value': 'test_ini_value'}]
@@ -102,6 +108,7 @@ def __iter__(self):
102108
mocked_session.items = [mocked_item]
103109

104110
rp_service.collect_tests(mocked_session)
111+
mocked_item.own_markers = []
105112
rp_service.start_pytest_item(mocked_item)
106113

107114
expect(mocked_item_start.call_count == 1, 'One HTTP POST sent')

0 commit comments

Comments
 (0)