Skip to content

Commit 89ca336

Browse files
authored
Merge pull request #420 from reportportal/develop
Release
2 parents ee8592c + 973603e commit 89ca336

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
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
### Fixed
5+
- Issue [#418](https://github.com/reportportal/agent-python-pytest/issues/418) parametrize marker IDs, by @drcrazy
6+
7+
## [5.6.4]
8+
### Fixed
59
- Agent crash in certain `pytest-bdd` cases, by @HardNorth
610

711
## [5.6.3]

pytest_reportportal/service.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
BACKGROUND_STEP_NAME = "Background"
9494

9595

96+
def _is_pytest_bdd_scenario(location_path: str) -> bool:
97+
"""
98+
Return True if the pytest collection path points at pytest-bdd's scenario module.
99+
100+
``Item.location[0]`` uses OS-native separators (backslashes on Windows), so a
101+
plain suffix check with ``/`` is not portable. See #418.
102+
"""
103+
return location_path.endswith(os.path.join("pytest_bdd", "scenario.py"))
104+
105+
96106
def trim_docstring(docstring: str) -> str:
97107
"""
98108
Convert docstring.
@@ -907,7 +917,7 @@ def start_pytest_item(self, test_item: Optional[Item] = None):
907917
if not self.__started():
908918
self.start()
909919

910-
if PYTEST_BDD and test_item.location[0].endswith("/pytest_bdd/scenario.py"):
920+
if PYTEST_BDD and _is_pytest_bdd_scenario(test_item.location[0]):
911921
self._bdd_item_by_name[test_item.name] = test_item
912922
return
913923

@@ -928,7 +938,7 @@ def process_results(self, test_item: Item, report):
928938
if report.longrepr:
929939
self.post_log(test_item, report.longreprtext, log_level="ERROR")
930940

931-
if PYTEST_BDD and test_item.location[0].endswith("/pytest_bdd/scenario.py"):
941+
if PYTEST_BDD and _is_pytest_bdd_scenario(test_item.location[0]):
932942
return
933943

934944
leaf = self._tree_path[test_item][-1]
@@ -1011,7 +1021,7 @@ def finish_pytest_item(self, test_item: Optional[Item] = None) -> None:
10111021
leaf = self._tree_path[test_item][-1]
10121022
self._process_metadata_item_finish(leaf)
10131023

1014-
if PYTEST_BDD and test_item.location[0].endswith("/pytest_bdd/scenario.py"):
1024+
if PYTEST_BDD and _is_pytest_bdd_scenario(test_item.location[0]):
10151025
del self._bdd_item_by_name[test_item.name]
10161026
return
10171027

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.6.4"
20+
__version__ = "5.6.5"
2121

2222

2323
def read_file(fname):

tests/unit/test_service.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@
1313

1414
"""This module includes unit tests for the service.py module."""
1515

16+
import os
17+
1618
from delayed_assert import assert_expectations, expect
1719

20+
from pytest_reportportal.service import _is_pytest_bdd_scenario
21+
22+
23+
def test_is_pytest_bdd_scenario_path():
24+
"""pytest-bdd scenario items use forward slashes in location on POSIX and backslashes on Windows."""
25+
path = os.path.join("project", "pytest_bdd", "scenario.py")
26+
assert _is_pytest_bdd_scenario(path) is True
27+
28+
29+
def test_is_pytest_bdd_scenario_regular_test_module():
30+
"""Regular tests must not be treated as pytest-bdd scenario glue."""
31+
assert _is_pytest_bdd_scenario("/project/tests/test_foo.py") is False
32+
1833

1934
def test_get_item_parameters(mocked_item, rp_service):
2035
"""Test that parameters are returned in a way supported by the client."""

0 commit comments

Comments
 (0)