Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not import rclpy nor launch_ros at module level. #69

Merged
merged 1 commit into from
Sep 11, 2019
Merged
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
5 changes: 2 additions & 3 deletions launch_testing_ros/launch_testing_ros/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
"""Module for a ROS aware LaunchTestRunner."""

import launch
import launch_ros
import launch_testing.test_runner

import rclpy


class LaunchTestRunner(launch_testing.test_runner.LaunchTestRunner):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
import rclpy # Import on first use to avoid races at module level
self._rclpy_context = rclpy.context.Context()
rclpy.init(args=self._launch_file_arguments, context=self._rclpy_context)

def generate_preamble(self):
import launch_ros # Import on first use to avoid races at module level
return [launch.actions.IncludeLaunchDescription(
launch_description_source=launch.LaunchDescriptionSource(
launch_description=launch_ros.get_default_launch_description(
Expand Down