Skip to content

Commit 61a271c

Browse files
committed
test: refactor connector shutdown logic in two test cases
1 parent 73677a5 commit 61a271c

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

tests/rai_perception/agents/test_base_vision_agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ def test_stop(self, tmp_path):
316316
agent = MockBaseVisionAgent(weights_root_path=str(tmp_path), ros2_name="test")
317317
agent.weights_path = weights_path
318318

319-
with patch.object(agent.ros2_connector, "shutdown") as mock_shutdown:
319+
with patch.object(
320+
agent.ros2_connector,
321+
"shutdown",
322+
wraps=agent.ros2_connector.shutdown,
323+
) as mock_shutdown:
320324
agent.stop()
321325
mock_shutdown.assert_called_once()
322-
323-
if rclpy.ok():
324-
rclpy.shutdown()

tests/rai_perception/tools/test_pcl_detection_tools.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def slow_operation(obj_name):
182182

183183
def test_get_object_gripping_points_tool_auto_declaration():
184184
"""Test that GetObjectGrippingPointsTool auto-declares parameters with defaults."""
185+
connector = None
185186
rclpy.init()
186187
try:
187188
connector = ROS2Connector(executor_type="single_threaded")
@@ -275,7 +276,10 @@ def test_get_object_gripping_points_tool_auto_declaration():
275276
assert "segmentation_service_name" in config
276277

277278
finally:
278-
rclpy.shutdown()
279+
if connector is not None:
280+
connector.shutdown()
281+
if rclpy.ok():
282+
rclpy.shutdown()
279283

280284

281285
def test_get_object_positions_tool_wrapper():

0 commit comments

Comments
 (0)