Skip to content

Commit aa16f98

Browse files
authored
Merge pull request #387 from reportportal/develop
Release
2 parents fbb7721 + 1ae302f commit aa16f98

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44
### Added
5+
- Escaping of binary symbol '\0' in parameters, by @HardNorth
6+
7+
## [5.4.6]
8+
### Added
59
- Support for `Python 3.13`, by @HardNorth
610
- Support for `name` Pytest marker, by @HardNorth
711
- `rp_hierarchy_test_file` configuration parameter, which controls display of test file name in the hierarchy, by @ramir-dn, @HardNorth
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""A simple example test with different parameter types."""
2+
import pytest
3+
4+
5+
BINARY_TEXT = 'Some text with binary symbol \0'
6+
7+
8+
@pytest.mark.parametrize(
9+
['text'], [[BINARY_TEXT]]
10+
)
11+
def test_in_class_parameterized(text):
12+
"""
13+
This is my test with different parameter types.
14+
"""
15+
assert text == BINARY_TEXT
16+
assert text != BINARY_TEXT.replace('\0', '\\0')

pytest_reportportal/service.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,17 @@ def _process_item_name(self, leaf: Dict[str, Any]) -> str:
592592
name = mark_name
593593
return name
594594

595-
def _get_parameters(self, item):
595+
def _get_parameters(self, item) -> Optional[Dict[str, Any]]:
596596
"""
597597
Get params of item.
598598
599599
:param item: Pytest.Item
600600
:return: dict of params
601601
"""
602-
return item.callspec.params if hasattr(item, 'callspec') else None
602+
params = item.callspec.params if hasattr(item, 'callspec') else None
603+
if not params:
604+
return None
605+
return {str(k): v.replace('\0', '\\0') if isinstance(v, str) else v for k, v in params.items()}
603606

604607
def _process_test_case_id(self, leaf):
605608
"""
@@ -650,7 +653,7 @@ def _process_attributes(self, item):
650653

651654
return [self._to_attribute(attribute) for attribute in attributes]
652655

653-
def _process_metadata_item_start(self, leaf: Dict[str, Any]):
656+
def _process_metadata_item_start(self, leaf: Dict[str, Any]) -> None:
654657
"""
655658
Process all types of item metadata for its start event.
656659
@@ -664,7 +667,7 @@ def _process_metadata_item_start(self, leaf: Dict[str, Any]):
664667
leaf['issue'] = self._process_issue(item)
665668
leaf['attributes'] = self._process_attributes(item)
666669

667-
def _process_metadata_item_finish(self, leaf: Dict[str, Any]):
670+
def _process_metadata_item_finish(self, leaf: Dict[str, Any]) -> None:
668671
"""
669672
Process all types of item metadata for its finish event.
670673
@@ -674,7 +677,7 @@ def _process_metadata_item_finish(self, leaf: Dict[str, Any]):
674677
leaf['attributes'] = self._process_attributes(item)
675678
leaf['issue'] = self._process_issue(item)
676679

677-
def _build_start_step_rq(self, leaf):
680+
def _build_start_step_rq(self, leaf: Dict[str, Any]) -> Dict[str, Any]:
678681
payload = {
679682
'attributes': leaf.get('attributes', None),
680683
'name': self._truncate_item_name(leaf['name']),
@@ -683,8 +686,7 @@ def _build_start_step_rq(self, leaf):
683686
'item_type': 'STEP',
684687
'code_ref': leaf.get('code_ref', None),
685688
'parameters': leaf.get('parameters', None),
686-
'parent_item_id': self._lock(leaf['parent'],
687-
lambda p: p['item_id']),
689+
'parent_item_id': self._lock(leaf['parent'], lambda p: p['item_id']),
688690
'test_case_id': leaf.get('test_case_id', None)
689691
}
690692
return payload

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from setuptools import setup
1919

2020

21-
__version__ = '5.4.6'
21+
__version__ = '5.4.7'
2222

2323

2424
def read_file(fname):

tests/integration/test_parameters_report.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pytest
1717
from unittest import mock
1818

19+
from examples.params.test_binary_symbol_in_parameters import BINARY_TEXT
1920
from tests import REPORT_PORTAL_SERVICE
2021
from tests.helpers import utils
2122

@@ -25,7 +26,8 @@
2526
('examples/test_simple.py', None),
2627
('examples/params/test_in_class_parameterized.py', {'param': 'param'}),
2728
('examples/params/test_different_parameter_types.py',
28-
{'integer': 1, 'floating_point': 1.5, 'boolean': True, 'none': None})
29+
{'integer': 1, 'floating_point': 1.5, 'boolean': True, 'none': None}),
30+
('examples/params/test_binary_symbol_in_parameters.py', {'text': BINARY_TEXT.replace('\0', '\\0')}),
2931
])
3032
def test_parameters(mock_client_init, test, expected_params):
3133
"""Verify different tests have correct parameters.

0 commit comments

Comments
 (0)