Why does launch_test result show "Ran 0 tests in 0.000 s" after running a test?
I am trying to write an integration test to test the ROS API of a node I am working on, and I followed some of the examples from the launch and launchros repos that use the launchtest tool.
The final output shows that 0 tests ran though, even though earlier up in the output I can see that it ran my test and it shows "Ran 1 test in 7.600s".
Is there anyway to stop it from printing "Ran 0 tests in 0.000s" at the end? And is there any way to get a cleaner output from launch_test that only shows the test result and not all the logging output from the test?
This is my test:
import pytest
from launch import LaunchDescription
from launch_ros.actions import Node
import rclpy
import unittest
from evergreen_cvml.instance_seg_service_client import InstanceSegServiceClient
from evergreen_common.topic_names import LEFT_REAR_CAMERA_LEFT_IMAGE_TOPIC
from rclpy.callback_groups import ReentrantCallbackGroup
from launch_testing.actions import ReadyToTest
import launch_ros.actions
import launch.launch_service
import launch_testing.io_handler
# Note: This test is trying to follow the launch_testing_ros pattern
# See this file for an example: https://github.com/ros2/launch_ros/blob/57362f296f600d46f140b084c14f04b241988d1d/launch_testing_ros/test/examples/talker_listener_launch_test.py
@pytest.mark.rostest
def generate_test_description() -> tuple[LaunchDescription, dict]:
image_publisher = Node(
package='evergreen_cvml',
executable='image_publisher.py',
name='image_publisher',
output='log'
)
cvml_node = Node(
package='evergreen_cvml',
executable='cvml_engine.py',
name='cvml_engine',
output='log'
)
return (
LaunchDescription([
cvml_node,
image_publisher,
ReadyToTest()
]),
{
'cvml_node': cvml_node,
'image_publisher': image_publisher
}
)
class TestTalkerListenerLink(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
# Initialize the ROS context for the test node
rclpy.init()
@classmethod
def tearDownClass(cls) -> None:
# Shutdown the ROS context
rclpy.shutdown()
def setUp(self) -> None:
# Create a ROS node for tests
self.node = rclpy.create_node('test_cvml_node')
def tearDown(self) -> None:
self.node.destroy_node()
def test_instance_seg(self,
launch_service: launch.launch_service.LaunchService,
cvml_node: launch_ros.actions.node.Node,
proc_output: launch_testing.io_handler.ActiveIoHandler) -> None:
self.node.get_logger().info('Testing instance segmentation service')
# Create service client to call the service
client = InstanceSegServiceClient(
self.node, LEFT_REAR_CAMERA_LEFT_IMAGE_TOPIC, ReentrantCallbackGroup())
seg_result = client.request()
self.assertIsNotNone(seg_result)
And the output from running it:
Blockquote lexiwinters@easybake-mini:~/workspace/evergreen/rosws$ launchtest src/evergreencvml/test/testinstancesegservice.py [INFO] [launch]: All log files can be found below /home/lexiwinters/.ros/log/2023-06-22-13-16-57-698115-easybake-mini-1482773 [INFO] [launch]: Default logging verbosity is set to INFO testinstanceseg (testinstancesegservice.TestTalkerListenerLink) ... [INFO] [cvml_engine.py-1]: process started with pid [1482800] [INFO] [imagepublisher.py-2]: process started with pid [1482802] [INFO] [1687461417.763161226] [testcvmlnode]: Testing instance segmentation service type of cvmlnode: <class 'launchros.actions.node.Node'> type of procoutput: <class 'launchtesting.iohandler.ActiveIoHandler'> type of launchservice:
[INFO] [1687461418.826184214] [testcvmlnode]: service not available, waiting again... [imagepublisher.py-2] [INFO] [1687461419.141978162] [imagepublisher]: publishing image [INFO] [1687461419.827805433] [testcvmlnode]: service not available, waiting again... [imagepublisher.py-2] [INFO] [1687461420.133853335] [imagepublisher]: publishing image [INFO] [1687461420.829693420] [testcvmlnode]: service not available, waiting again... [imagepublisher.py-2] [INFO] [1687461421.133861759] [imagepublisher]: publishing image [INFO] [1687461421.831521120] [testcvmlnode]: service not available, waiting again... [imagepublisher.py-2] [INFO] [1687461422.133862389] [imagepublisher]: publishing image [INFO] [1687461422.833355555] [testcvmlnode]: service not available, waiting again... [INFO] [1687461423.086667059] [testcvmlnode]: requesting instance segmentation [imagepublisher.py-2] [INFO] [1687461423.133889308] [imagepublisher]: publishing image [cvmlengine.py-1] [INFO] [1687461423.250433859] [instancesegmentationnode]: Received instance segmentation request [cvmlengine.py-1] [INFO] [1687461423.250713800] [instancesegmentation_node]: Processing image 0 from request [imagepublisher.py-2] [INFO] [1687461424.133845092] [imagepublisher]: publishing image [cvmlengine.py-1] /home/lexiwinters/.local/lib/python3.10/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.) [cvmlengine.py-1] return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] [image_publisher.py-2] [INFO] [1687461425.133853663] [imagepublisher]: publishing image [cvmlengine.py-1] [INFO] [1687461425.235535700] [cvmlros_visualizer]: Publishing visualization [cvmlengine.py-1] [INFO] [1687461425.236740740] [cvmlros_visualizer]: 6 instances from image 0 ok
Ran 1 test in 7.600s
OK
[INFO] [imagepublisher.py-2]: sending signal 'SIGINT' to process[image_publisher.py-2]
[INFO] [cvmlengine.py-1]: sending signal 'SIGINT' to process[cvmlengine.py-1]
[imagepublisher.py-2] Traceback (most recent call last):
[imagepublisher.py-2] File "/home/lexiwinters/workspace/evergreen/rosws/install/evergreencvml/lib/evergreencvml/imagepublisher.py", line 48, in
Ran 0 tests in 0.000s
OK lexiwinters@easybake-mini:~/workspace/evergreen/ros_ws$
Asked by lexi on 2023-06-22 14:48:53 UTC
Comments