Skip to content

Commit ed45ebb

Browse files
authored
Move pytest entrypoints to own module (ros2#278)
Signed-off-by: Shane Loretz <[email protected]>
1 parent 6410f6c commit ed45ebb

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

launch_testing_ros/launch_testing_ros/pytest/hooks.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,3 @@ class LaunchROSTestModule(LaunchTestModule):
3333

3434
def makeitem(self, *args, **kwargs):
3535
return LaunchROSTestItem.from_parent(*args, **kwargs)
36-
37-
38-
def pytest_launch_collect_makemodule(path, parent, entrypoint):
39-
marks = getattr(entrypoint, 'pytestmark', [])
40-
if marks and any(m.name == 'rostest' for m in marks):
41-
return LaunchROSTestModule.from_parent(parent=parent, fspath=path)
42-
43-
44-
def pytest_configure(config):
45-
config.addinivalue_line(
46-
'markers',
47-
'rostest: mark a generate_test_description function as a ROS launch test entrypoint'
48-
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2019 Open Source Robotics Foundation, Inc.
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+
# http://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+
# Only import standard python modules here
16+
# This module intentionally delays imports as late as possible to avoid
17+
# importing downstream modules in upstream packages when built with a merged
18+
# workspace.
19+
20+
21+
def pytest_launch_collect_makemodule(path, parent, entrypoint):
22+
marks = getattr(entrypoint, 'pytestmark', [])
23+
if marks and any(m.name == 'rostest' for m in marks):
24+
from launch_testing_ros.pytest.hooks import LaunchROSTestModule
25+
return LaunchROSTestModule.from_parent(parent=parent, fspath=path)
26+
27+
28+
def pytest_configure(config):
29+
config.addinivalue_line(
30+
'markers',
31+
'rostest: mark a generate_test_description function as a ROS launch test entrypoint'
32+
)

launch_testing_ros/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
name='launch_testing_ros',
88
version='0.15.0',
99
packages=find_packages(exclude=['test']),
10+
py_modules=['launch_testing_ros_pytest_entrypoint'],
1011
data_files=[
1112
('share/ament_index/resource_index/packages', ['resource/launch_testing_ros']),
1213
('share/launch_testing_ros', ['package.xml']),
1314
('share/launch_testing_ros/examples', glob.glob('test/examples/[!_]*.*')),
1415
],
1516
entry_points={
16-
'pytest11': ['launch_ros = launch_testing_ros.pytest.hooks'],
17+
'pytest11': ['launch_ros = launch_testing_ros_pytest_entrypoint'],
1718
},
1819
install_requires=['setuptools'],
1920
zip_safe=True,

0 commit comments

Comments
 (0)