Skip to content

Instantly share code, notes, and snippets.

@mikaelarguedas
Last active July 5, 2016 17:50
Show Gist options
  • Save mikaelarguedas/85a7eebb1dafe1a73c3b26d95ca075e3 to your computer and use it in GitHub Desktop.
Save mikaelarguedas/85a7eebb1dafe1a73c3b26d95ca075e3 to your computer and use it in GitHub Desktop.
launch environment passing fail
import os
print(os.environ.get('testenv2', 'Not Set'))
print(os.environ.get('testenv1', 'Not Set'))
assert(os.environ.get('testenv2', 'Not Set') == 'testval2')
assert(os.environ.get('testenv1', 'Not Set') == 'testval1')
import os
import sys
from launch import LaunchDescriptor
from launch.launcher import DefaultLauncher
from launch.exit_handler import primary_exit_handler
def test_env():
ld = LaunchDescriptor()
sub_env = dict(os.environ)
sub_env['testenv1'] = 'testval1'
os.environ['testenv2'] = 'testval2'
ld.add_process(
cmd=[sys.executable, '/home/mikael/work/ros2/ros2_ws/src/ros2/launch/launch_testing/test/check_env.py'],
name='test_env',
env=sub_env,
exit_handler=primary_exit_handler,
)
launcher = DefaultLauncher()
launcher.add_launch_descriptor(ld)
rc = launcher.launch()
assert rc == 0, \
"The launch file failed with exit code '" + str(rc) + "'. "
if __name__ == '__main__':
test_env()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment