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
16 changes: 14 additions & 2 deletions launch_testing_ros/launch_testing_ros_pytest_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@
# importing downstream modules in upstream packages when built with a merged
# workspace.

import pathlib

import pytest


def pytest_launch_collect_makemodule(path, parent, entrypoint):
def _pytest_version_ge(major, minor=0, patch=0):
"""Return True if pytest version is >= the given version."""
pytest_version = tuple([int(v) for v in pytest.__version__.split('.')])
return pytest_version >= (major, minor, patch)


def pytest_launch_collect_makemodule(module_path, parent, entrypoint):
marks = getattr(entrypoint, 'pytestmark', [])
if marks and any(m.name == 'rostest' for m in marks):
from launch_testing_ros.pytest.hooks import LaunchROSTestModule
module = LaunchROSTestModule.from_parent(parent=parent, fspath=path)
if _pytest_version_ge(7):
path = pathlib.Path(module_path)
module = LaunchROSTestModule.from_parent(parent=parent, path=path)
else:
module = LaunchROSTestModule.from_parent(parent=parent, fspath=module_path)
for mark in marks:
decorator = getattr(pytest.mark, mark.name)
decorator = decorator.with_args(*mark.args, **mark.kwargs)
Expand Down
7 changes: 2 additions & 5 deletions launch_testing_ros/test/examples/check_msgs_launch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ def subscription_callback(self, data: String):
self.msg_event_object.set()

def spin(self):
try:
while rclpy.ok() and not self.spinning.is_set():
rclpy.spin_once(self.node, timeout_sec=0.1)
finally:
return
while rclpy.ok() and not self.spinning.is_set():
rclpy.spin_once(self.node, timeout_sec=0.1)

def setUp(self):
rclpy.init()
Expand Down