[ROS2] [launch_pytest] node outputting to stderr instead of stdout
As asked by @clalancette, I am reposting launch issue #619 here.
- Operating System:
- Ubuntu 20.04.4
- ROS2 Distro:
- foxy
- Version or commit hash:
- launch: 1.1.0
- (launch_ros: 0.20.0)
- (pytest: 7.1.2)
- DDS implementation:
- rmw_cyclonedds_cpp
- Client library (if applicable):
- rclpy
Steps to reproduce issue
copy-paste the following in test_confusing.py
, then run pytest test_confusing.py
import launch
import launch_pytest
import launch_ros
import pytest
@pytest.fixture
def foo_node_process() -> launch.actions.ExecuteProcess:
return launch_ros.actions.Node(
package='examples_rclpy_minimal_client', executable='client', name='client', output='screen', cached_output=True
)
@launch_pytest.fixture
def foo_launch_description(foo_node_process) -> launch.LaunchDescription:
return launch.LaunchDescription([foo_node_process])
@pytest.mark.launch(fixture=foo_launch_description)
def test_read_foo_stdout(foo_node_process, launch_context):
assert launch_pytest.tools.wait_for_start_sync(launch_context, foo_node_process, timeout=5)
def validate_output(output: str):
assert len(output) > 0, 'Output is empty'
# passes
launch_pytest.tools.assert_stderr_sync(launch_context, foo_node_process, validate_output, timeout=5)
# fails
launch_pytest.tools.assert_output_sync(launch_context, foo_node_process, validate_output, timeout=5)
Expected behavior
The output of the launched node (logging info messages "service not available, waiting again..."
) should be in stdout
.
Actual behavior
The output is in stderr
, causing a confusing fail of the test.
Additional information
I am a bit confused by the output='screen'
argument and the fact that the pytest_hello_world.py
is using assert_output_sync
. However, it is maybe intended behavior, as running ros2 run examples_rclpy_minimal_client client
also outputs to stderr
.
Is it normal? Could you help me understand?
Thanks!