Skip to content

Comments

fix(tests): check for ros#1361

Open
paul-nechifor wants to merge 1 commit intodevfrom
paul/fix/check-for-ros
Open

fix(tests): check for ros#1361
paul-nechifor wants to merge 1 commit intodevfrom
paul/fix/check-for-ros

Conversation

@paul-nechifor
Copy link
Contributor

@paul-nechifor paul-nechifor commented Feb 24, 2026

Problem

ERROR dimos/protocol/pubsub/impl/test_rospubsub.py::test_basic_conversion - ImportError: rclpy is not installed. ROS pubsub requires ROS 2.
ERROR dimos/protocol/pubsub/impl/test_rospubsub.py::test_pointcloud2_empty_pubsub - ImportError: rclpy is not installed. ROS pubsub requires ROS 2.
ERROR dimos/protocol/pubsub/impl/test_rospubsub.py::test_posestamped_pubsub - ImportError: rclpy is not installed. ROS pubsub requires ROS 2.
ERROR dimos/protocol/pubsub/impl/test_rospubsub.py::test_pointstamped_pubsub - ImportError: rclpy is not installed. ROS pubsub requires ROS 2.
ERROR dimos/protocol/pubsub/impl/test_rospubsub.py::test_twist_pubsub - ImportError: rclpy is not installed. ROS pubsub requires ROS 2

Solution

Skip those tests if rclpy is not available.

Breaking Changes

None.

How to Test

uv run pytest dimos/protocol/pubsub/impl/test_rospubsub.py

Contributor License Agreement

  • I have read and approved the CLA.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

Added skipif_no_ros marker to gracefully skip ROS-dependent tests when ROS dependencies (rclpy) are not installed. The implementation includes a new _has_ros() helper function in conftest.py and applies the marker to all six test functions in test_rospubsub.py.

Key issues:

  • Pytest fixtures execute before test-level skip markers, so the publisher and subscriber fixtures will still attempt to instantiate DimosROS() and raise ImportError when ROS is unavailable, before tests can be skipped
  • Consider using module-level pytestmark or pytest.importorskip() in the fixtures to properly skip fixture setup

Confidence Score: 3/5

  • This PR has a logical issue with fixture execution timing that may cause failures instead of skips
  • The test-level skip markers won't prevent fixture setup failures. When ROS is unavailable, the fixtures will raise ImportError before pytest can skip the tests, defeating the purpose of the skip markers
  • Pay close attention to dimos/protocol/pubsub/impl/test_rospubsub.py - the fixtures need conditional execution logic

Important Files Changed

Filename Overview
dimos/conftest.py Added skipif_no_ros marker and _has_ros() helper function to enable conditional test skipping when ROS dependencies are not installed
dimos/protocol/pubsub/impl/test_rospubsub.py Applied @pytest.mark.skipif_no_ros to all test functions, but fixtures may still fail during setup if ROS is unavailable

Last reviewed commit: 797ca98

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Additional Comments (1)

dimos/protocol/pubsub/impl/test_rospubsub.py
Fixtures will execute before test-level skip markers take effect. If ROS is not installed, DimosROS() on line 35 will raise ImportError during fixture setup, before pytest can skip the test.

Consider adding pytestmark = pytest.mark.skipif_no_ros at the module level (top of file) to skip the entire module, or make the fixtures conditional:

@pytest.fixture()
def publisher() -> Generator[DimosROS, None, None]:
    pytest.importorskip("rclpy", reason="ROS dependencies not available")
    yield from ros_node()


@pytest.fixture()
def subscriber() -> Generator[DimosROS, None, None]:
    pytest.importorskip("rclpy", reason="ROS dependencies not available")
    yield from ros_node()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant