Skip to content
Open
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
6 changes: 3 additions & 3 deletions launch_testing_ros/launch_testing_ros_pytest_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def _pytest_version_ge(major, minor=0, patch=0):
return pytest_version >= (major, minor, patch)


def pytest_launch_collect_makemodule(module_path, parent, entrypoint):
def pytest_launch_collect_makemodule(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
if _pytest_version_ge(7):
path = pathlib.Path(module_path)
path = pathlib.Path(path)
module = LaunchROSTestModule.from_parent(parent=parent, path=path)
else:
module = LaunchROSTestModule.from_parent(parent=parent, fspath=module_path)
module = LaunchROSTestModule.from_parent(parent=parent, fspath=path)
for mark in marks:
decorator = getattr(pytest.mark, mark.name)
decorator = decorator.with_args(*mark.args, **mark.kwargs)
Expand Down
39 changes: 39 additions & 0 deletions launch_testing_ros/test/test_pytest_entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2026 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import launch_testing_ros_pytest_entrypoint
import pytest


class LegacyLaunchTestingHooks:

@pytest.hookspec(firstresult=True)
def pytest_launch_collect_makemodule(path, parent, entrypoint):
pass


class CurrentLaunchTestingHooks:

@pytest.hookspec(firstresult=True)
def pytest_launch_collect_makemodule(module_path, path, parent, entrypoint):
pass


@pytest.mark.parametrize(
'hookspecs', [LegacyLaunchTestingHooks, CurrentLaunchTestingHooks]
)
def test_pytest_entrypoint_hook_compatibility(hookspecs):
manager = pytest.PytestPluginManager()
manager.add_hookspecs(hookspecs)
manager.register(launch_testing_ros_pytest_entrypoint, 'launch_ros')