Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]
### Fixed
- Issue [#418](https://github.com/reportportal/agent-python-pytest/issues/418) parametrize marker IDs, by @drcrazy

## [5.6.4]
### Fixed
- Agent crash in certain `pytest-bdd` cases, by @HardNorth

## [5.6.3]
Expand Down
16 changes: 13 additions & 3 deletions pytest_reportportal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@
BACKGROUND_STEP_NAME = "Background"


def _is_pytest_bdd_scenario(location_path: str) -> bool:
"""
Return True if the pytest collection path points at pytest-bdd's scenario module.

``Item.location[0]`` uses OS-native separators (backslashes on Windows), so a
plain suffix check with ``/`` is not portable. See #418.
"""
return location_path.endswith(os.path.join("pytest_bdd", "scenario.py"))


def trim_docstring(docstring: str) -> str:
"""
Convert docstring.
Expand Down Expand Up @@ -907,7 +917,7 @@ def start_pytest_item(self, test_item: Optional[Item] = None):
if not self.__started():
self.start()

if PYTEST_BDD and test_item.location[0].endswith("/pytest_bdd/scenario.py"):
if PYTEST_BDD and _is_pytest_bdd_scenario(test_item.location[0]):
self._bdd_item_by_name[test_item.name] = test_item
return

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

if PYTEST_BDD and test_item.location[0].endswith("/pytest_bdd/scenario.py"):
if PYTEST_BDD and _is_pytest_bdd_scenario(test_item.location[0]):
return

leaf = self._tree_path[test_item][-1]
Expand Down Expand Up @@ -1011,7 +1021,7 @@ def finish_pytest_item(self, test_item: Optional[Item] = None) -> None:
leaf = self._tree_path[test_item][-1]
self._process_metadata_item_finish(leaf)

if PYTEST_BDD and test_item.location[0].endswith("/pytest_bdd/scenario.py"):
if PYTEST_BDD and _is_pytest_bdd_scenario(test_item.location[0]):
del self._bdd_item_by_name[test_item.name]
return

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from setuptools import setup

__version__ = "5.6.4"
__version__ = "5.6.5"


def read_file(fname):
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@

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

import os

from delayed_assert import assert_expectations, expect

from pytest_reportportal.service import _is_pytest_bdd_scenario


def test_is_pytest_bdd_scenario_path():
"""pytest-bdd scenario items use forward slashes in location on POSIX and backslashes on Windows."""
path = os.path.join("project", "pytest_bdd", "scenario.py")
assert _is_pytest_bdd_scenario(path) is True


def test_is_pytest_bdd_scenario_regular_test_module():
"""Regular tests must not be treated as pytest-bdd scenario glue."""
assert _is_pytest_bdd_scenario("/project/tests/test_foo.py") is False


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