Skip to content

Commit 0248163

Browse files
authored
Merge pull request #400 from reportportal/develop
Release
2 parents d219243 + 72c0eaa commit 0248163

File tree

13 files changed

+263
-24
lines changed

13 files changed

+263
-24
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ jobs:
5656
- name: Build package
5757
run: python setup.py sdist bdist_wheel
5858

59-
# - name: Publish package
60-
# uses: pypa/gh-action-pypi-publish@release/v1
61-
# with:
62-
# user: ${{ secrets.PYPI_USERNAME }}
63-
# password: ${{ secrets.PYPI_PASSWORD }}
59+
- name: Publish package
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+
with:
62+
user: ${{ secrets.PYPI_USERNAME }}
63+
password: ${{ secrets.PYPI_PASSWORD }}
6464

6565
- name: Setup git credentials
6666
uses: oleksiyrudenko/gha-git-credentials@v2-latest
@@ -69,11 +69,11 @@ jobs:
6969
7070
token: ${{ secrets.GITHUB_TOKEN }}
7171

72-
# - name: Tagging new version
73-
# id: newVersionTag
74-
# run: |
75-
# git tag -a ${{ env.RELEASE_VERSION }} -m "Release ${{ env.RELEASE_VERSION }}"
76-
# git push --tags
72+
- name: Tagging new version
73+
id: newVersionTag
74+
run: |
75+
git tag -a ${{ env.RELEASE_VERSION }} -m "Release ${{ env.RELEASE_VERSION }}"
76+
git push --tags
7777
7878
- name: Checkout develop branch
7979
uses: actions/checkout@v4
@@ -108,13 +108,13 @@ jobs:
108108
version: ${{ env.RELEASE_VERSION }}
109109
path: ./${{ env.CHANGE_LOG_FILE }}
110110

111-
# - name: Create Release
112-
# id: createRelease
113-
# uses: ncipollo/release-action@v1
114-
# with:
115-
# tag: ${{ env.RELEASE_VERSION }}
116-
# name: Release ${{ env.RELEASE_VERSION }}
117-
# body: ${{ steps.readChangelogEntry.outputs.changes }}
111+
- name: Create Release
112+
id: createRelease
113+
uses: ncipollo/release-action@v1
114+
with:
115+
tag: ${{ env.RELEASE_VERSION }}
116+
name: Release ${{ env.RELEASE_VERSION }}
117+
body: ${{ steps.readChangelogEntry.outputs.changes }}
118118

119119
- name: Update version file
120120
id: versionFileUpdate

CHANGELOG.md

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

33
## [Unreleased]
44
### Added
5+
- Too long BDD Step name truncation on reporting, by @HardNorth
6+
- `use_index` parameter for `@pytest.mark.parametrize` decorator, which replaces parameter values with their indexes in the list, by @ramir-dn
7+
8+
## [5.5.0]
9+
### Added
510
- Issue [#357](https://github.com/reportportal/agent-python-pytest/issues/357) `pytest-bdd` support, by @HardNorth
611
### Fixed
712
- Issue [#389](https://github.com/reportportal/agent-python-pytest/issues/389) `rp_tests_attributes` configuration parameter handling, by @HardNorth
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Feature: Test long step scenario
2+
3+
Scenario: The scenario
4+
Given A very long step. Seriously, this step is ridiculously long. Our users require such a long step and here it is. This is not even a half of the step, it will last really long. I believe you will get tired before you reach the end of the step. Why? Because our users send here a megabyte-length JSONs or things like that, despite our words that this is not good for user experience, since it's hard to read such a long lines on UI and for backend performance, since we use this field in full-text search. OK I'm out of thought what else I can write here, but the step must go on. Probably you will see some random typing soon to get the step longer than it's right now. Because only now we crossed a half of the length we need. Alright, here we go: 39248cht42 3x,r093mhxr0,3hr c089r3423 xk309,,r3 k302uk032 3249xul398u3 at 34r9k39489 aumvi xkr293jed0 i 93u9f32u smhf 09ktc903 a tu09r328 ef5u0fu3v 0k8utf2 u59du9v u423kuc 9f5kv 39kd3uf39 -3940u5kfu5 b3-90485l-k3f. Are you tired? I'm too, but we still need a few words at the end.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2025 EPAM Systems
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import logging
16+
17+
from pytest_bdd import given, scenarios
18+
19+
# Import the scenario from the feature file
20+
scenarios("../features/long_step_scenario.feature")
21+
22+
23+
LOGGER = logging.getLogger(__name__)
24+
25+
26+
@given(
27+
"A very long step. Seriously, this step is ridiculously long. Our users require such a long step and here it is. This is not even a half of the step, it will last really long. I believe you will get tired before you reach the end of the step. Why? Because our users send here a megabyte-length JSONs or things like that, despite our words that this is not good for user experience, since it's hard to read such a long lines on UI and for backend performance, since we use this field in full-text search. OK I'm out of thought what else I can write here, but the step must go on. Probably you will see some random typing soon to get the step longer than it's right now. Because only now we crossed a half of the length we need. Alright, here we go: 39248cht42 3x,r093mhxr0,3hr c089r3423 xk309,,r3 k302uk032 3249xul398u3 at 34r9k39489 aumvi xkr293jed0 i 93u9f32u smhf 09ktc903 a tu09r328 ef5u0fu3v 0k8utf2 u59du9v u423kuc 9f5kv 39kd3uf39 -3940u5kfu5 b3-90485l-k3f. Are you tired? I'm too, but we still need a few words at the end." # noqa: E501
28+
)
29+
def step_with_long_text():
30+
LOGGER.info("Step with extremely long text executed successfully")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""A simple example test with Test Case ID decorator using parameter values."""
2+
3+
# Copyright (c) 2023 https://reportportal.io .
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
16+
import pytest
17+
18+
TEST_CASE_ID = "ISSUE-USE-INDEX-FALSE"
19+
20+
21+
@pytest.mark.parametrize(("param1", "param2"), [("value1", "value2")])
22+
@pytest.mark.tc_id(TEST_CASE_ID, parameterized=True, use_index=False)
23+
def test_case_id_decorator(param1, param2):
24+
assert True
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""A simple example test with Test Case ID decorator using parameter indices with selected params."""
2+
3+
# Copyright (c) 2023 https://reportportal.io .
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
16+
import pytest
17+
18+
TEST_CASE_ID = "ISSUE-USE-INDEX-PARTIAL"
19+
20+
21+
@pytest.mark.parametrize(("param1", "param2"), [("value1", "value2")])
22+
@pytest.mark.tc_id(TEST_CASE_ID, parameterized=True, params=["param1"], use_index=True)
23+
def test_case_id_decorator(param1, param2):
24+
assert True
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""A simple example test with Test Case ID decorator using parameter indices."""
2+
3+
# Copyright (c) 2023 https://reportportal.io .
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
16+
import pytest
17+
18+
TEST_CASE_ID = "ISSUE-USE-INDEX-TRUE"
19+
20+
21+
@pytest.mark.parametrize(("param1", "param2"), [("value1", "value2")])
22+
@pytest.mark.tc_id(TEST_CASE_ID, parameterized=True, use_index=True)
23+
def test_case_id_decorator(param1, param2):
24+
assert True

pytest_reportportal/service.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,18 +599,26 @@ def _get_code_ref(self, item: Item) -> str:
599599

600600
def _get_test_case_id(self, mark, leaf: Dict[str, Any]) -> str:
601601
parameters: Optional[Dict[str, Any]] = leaf.get("parameters", None)
602+
parameters_indices: Optional[Dict[str, Any]] = leaf.get("parameters_indices") or {}
602603
parameterized = True
603604
selected_params: Optional[List[str]] = None
605+
use_index = False
604606
if mark is not None:
605607
parameterized = mark.kwargs.get("parameterized", False)
606608
selected_params: Optional[Union[str, List[str]]] = mark.kwargs.get("params", None)
609+
use_index = mark.kwargs.get("use_index", False)
607610
if selected_params is not None and not isinstance(selected_params, list):
608611
selected_params = [selected_params]
609612

610613
param_str = None
611614
if parameterized and parameters is not None and len(parameters) > 0:
612615
if selected_params is not None and len(selected_params) > 0:
613-
param_list = [str(parameters.get(param, None)) for param in selected_params]
616+
if use_index:
617+
param_list = [str((param, parameters_indices.get(param, None))) for param in selected_params]
618+
else:
619+
param_list = [str(parameters.get(param, None)) for param in selected_params]
620+
elif use_index:
621+
param_list = [str(param) for param in parameters_indices.items()]
614622
else:
615623
param_list = [str(param) for param in parameters.values()]
616624
param_str = "[{}]".format(",".join(sorted(param_list)))
@@ -729,6 +737,19 @@ def _get_parameters(self, item) -> Optional[Dict[str, Any]]:
729737
return None
730738
return {str(k): v.replace("\0", "\\0") if isinstance(v, str) else v for k, v in params.items()}
731739

740+
def _get_parameters_indices(self, item) -> Optional[Dict[str, Any]]:
741+
"""
742+
Get params indices of item.
743+
744+
:param item: Pytest.Item
745+
:return: dict of params indices
746+
"""
747+
indices = item.callspec.indices if hasattr(item, "callspec") else None
748+
if not indices:
749+
return None
750+
751+
return indices
752+
732753
def _process_test_case_id(self, leaf: Dict[str, Any]) -> str:
733754
"""
734755
Process Test Case ID if set.
@@ -793,6 +814,7 @@ def _process_metadata_item_start(self, leaf: Dict[str, Any]) -> None:
793814
leaf["name"] = self._process_item_name(leaf)
794815
leaf["description"] = self._get_item_description(item)
795816
leaf["parameters"] = self._get_parameters(item)
817+
leaf["parameters_indices"] = self._get_parameters_indices(item)
796818
leaf["code_ref"] = self._get_code_ref(item)
797819
leaf["test_case_id"] = self._process_test_case_id(leaf)
798820
leaf["issue"] = self._process_issue(item)
@@ -1279,7 +1301,7 @@ def start_bdd_step(self, feature: Feature, scenario: Scenario, step: Step) -> No
12791301
if feature.background:
12801302
background_leaf = scenario_leaf["children"][feature.background]
12811303
self._finish_bdd_step(background_leaf, "PASSED")
1282-
item_id = reporter.start_nested_step(f"{step.keyword} {step.name}", timestamp())
1304+
item_id = reporter.start_nested_step(self._truncate_item_name(f"{step.keyword} {step.name}"), timestamp())
12831305
step_leaf["item_id"] = item_id
12841306
step_leaf["exec"] = ExecStatus.IN_PROGRESS
12851307

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dill>=0.3.6
22
pytest>=4.6.10
3-
reportportal-client~=5.6.2
3+
reportportal-client~=5.6.4
44
aenum>=3.1.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from setuptools import setup
1919

20-
__version__ = "5.5.0"
20+
__version__ = "5.5.1"
2121

2222

2323
def read_file(fname):

0 commit comments

Comments
 (0)