1919
2020from launch import LaunchDescription
2121from launch .actions import ExecuteProcess
22+ from launch .actions import SetEnvironmentVariable
2223
2324from launch_ros .actions import Node
2425
2728import launch_testing .asserts
2829import launch_testing .markers
2930import launch_testing .tools
31+ from launch_testing_ros .actions import EnableRmwIsolation
3032import launch_testing_ros .tools
3133
3234import pytest
@@ -49,6 +51,7 @@ def generate_test_description(rmw_implementation):
4951 path_to_fixtures = os .path .join (os .path .dirname (__file__ ), 'fixtures' )
5052 additional_env = get_rmw_additional_env (rmw_implementation )
5153 additional_env ['PYTHONUNBUFFERED' ] = '1'
54+ set_env_actions = [SetEnvironmentVariable (k , v ) for k , v in additional_env .items ()]
5255
5356 path_to_incompatible_talker_node_script = os .path .join (
5457 path_to_fixtures , 'talker_node_with_best_effort_qos.py' )
@@ -62,25 +65,21 @@ def generate_test_description(rmw_implementation):
6265 executable = sys .executable ,
6366 arguments = [path_to_compatible_talker_node_script ],
6467 remappings = [('chatter' , 'compatible_chatter' )],
65- additional_env = additional_env
6668 )
6769 listener_node_compatible = Node (
6870 executable = sys .executable ,
6971 arguments = [path_to_listener_node_script ],
7072 remappings = [('chatter' , 'compatible_chatter' )],
71- additional_env = additional_env
7273 )
7374 talker_node_incompatible = Node (
7475 executable = sys .executable ,
7576 arguments = [path_to_incompatible_talker_node_script ],
7677 remappings = [('chatter' , 'incompatible_chatter' )],
77- additional_env = additional_env
7878 )
7979 listener_node_incompatible = Node (
8080 executable = sys .executable ,
8181 arguments = [path_to_listener_node_script ],
8282 remappings = [('chatter' , 'incompatible_chatter' )],
83- additional_env = additional_env
8483 )
8584
8685 return LaunchDescription ([
@@ -89,6 +88,8 @@ def generate_test_description(rmw_implementation):
8988 cmd = ['ros2' , 'daemon' , 'stop' ],
9089 name = 'daemon-stop' ,
9190 on_exit = [
91+ * set_env_actions ,
92+ EnableRmwIsolation (),
9293 ExecuteProcess (
9394 cmd = ['ros2' , 'daemon' , 'start' ],
9495 name = 'daemon-start' ,
@@ -100,7 +101,6 @@ def generate_test_description(rmw_implementation):
100101 listener_node_compatible ,
101102 launch_testing .actions .ReadyToTest ()
102103 ],
103- additional_env = additional_env
104104 )
105105 ]
106106 ),
@@ -128,11 +128,8 @@ def setUpClass(
128128
129129 @contextlib .contextmanager
130130 def launch_doctor_command (self , arguments ):
131- additional_env = get_rmw_additional_env (rmw_implementation )
132- additional_env ['PYTHONUNBUFFERED' ] = '1'
133131 doctor_command_action = ExecuteProcess (
134132 cmd = ['ros2' , 'doctor' , * arguments ],
135- additional_env = additional_env ,
136133 name = 'ros2doctor-cli' ,
137134 output = 'screen'
138135 )
0 commit comments