1515from threading import Thread
1616from unittest import mock
1717
18+ import lifecycle_msgs .msg
19+ import lifecycle_msgs .srv
20+
1821import pytest
1922
2023import rclpy
24+ from rclpy .executors import SingleThreadedExecutor
2125from rclpy .impl .implementation_singleton import rclpy_implementation as _rclpy
2226from rclpy .lifecycle import LifecycleNode
2327from rclpy .lifecycle import TransitionCallbackReturn
24- from rclpy .executors import SingleThreadedExecutor
2528from rclpy .node import Node
2629from rclpy .publisher import Publisher
2730
28- import lifecycle_msgs .msg
29- import lifecycle_msgs .srv
3031from test_msgs .msg import BasicTypes
3132
3233
@@ -129,15 +130,16 @@ def test_lifecycle_services(request):
129130 ):
130131 assert cli .wait_for_service (5. )
131132 # lunch a thread to spin the executor, so we can make sync service calls easily
132- exec = SingleThreadedExecutor ()
133- exec .add_node (client_node )
134- exec .add_node (lc_node )
135- thread = Thread (target = exec .spin )
133+ executor = SingleThreadedExecutor ()
134+ executor .add_node (client_node )
135+ executor .add_node (lc_node )
136+ thread = Thread (target = executor .spin )
136137 thread .start ()
138+
137139 def cleanup ():
138140 # Stop executor and join thread.
139141 # This cleanup is run even if an assertion fails.
140- exec .shutdown ()
142+ executor .shutdown ()
141143 thread .join ()
142144 request .addfinalizer (cleanup )
143145
@@ -161,13 +163,15 @@ def cleanup():
161163 }
162164 req = lifecycle_msgs .srv .GetAvailableTransitions .Request ()
163165 resp = get_available_transitions_cli .call (req )
164- transitions_labels = {transition_def .transition .label for transition_def in resp .available_transitions }
166+ transitions_labels = {
167+ transition_def .transition .label for transition_def in resp .available_transitions }
165168 assert transitions_labels == {'activate' , 'cleanup' , 'shutdown' }
166169 req = lifecycle_msgs .srv .GetAvailableTransitions .Request ()
167170 resp = get_transition_graph_cli .call (req )
168- transitions_labels = {transition_def .transition .label for transition_def in resp .available_transitions }
171+ transitions_labels = {
172+ transition_def .transition .label for transition_def in resp .available_transitions }
169173 assert transitions_labels == {
170- 'configure' , 'activate' , 'cleanup' , 'shutdown' , 'deactivate' , 'transition_error' ,
174+ 'configure' , 'activate' , 'cleanup' , 'shutdown' , 'deactivate' , 'transition_error' ,
171175 'transition_failure' , 'transition_success'
172176 }
173177
0 commit comments