Skip to content

Commit

Permalink
Properly mock out all submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdivo committed Jan 4, 2025
1 parent 65504bd commit fef107f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,33 @@
import re
import sys
from pathlib import Path
from unittest.mock import Mock

# -- Mock ROS2 ---------------------------------------------------------------

try:
import rclpy
except ImportError:
sys.modules["rclpy"] = Mock()
from unittest.mock import NonCallableMock

for module in [
"rclpy",
"rclpy.action",
"rclpy.action.client",
"rclpy.callback_groups",
"rclpy.client",
"rclpy.context",
"rclpy.executors",
"rclpy.node",
"rclpy.parameter",
"rclpy.publisher",
"rclpy.qos",
"rclpy.task",
"action_msgs.msg",
]:
sys.modules[module] = NonCallableMock()
else:
del rclpy

try:
import action_msgs
except ImportError:
sys.modules["action_msgs"] = Mock()
else:
del action_msgs

# -- Project information -----------------------------------------------------

project = "ROS2 easy-test"
Expand Down

0 comments on commit fef107f

Please sign in to comment.