mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-17 09:39:47 +00:00
fix fast tests
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
from lerobot.motors.motors_bus import (
|
||||
Motor,
|
||||
MotorsBus,
|
||||
MotorsBusBase,
|
||||
)
|
||||
|
||||
DUMMY_CTRL_TABLE_1 = {
|
||||
@@ -122,6 +123,12 @@ class MockPortHandler:
|
||||
|
||||
|
||||
class MockMotorsBus(MotorsBus):
|
||||
"""Mock motor bus that bypasses hardware dependency checks.
|
||||
|
||||
Inherits from MotorsBus (alias for SerialMotorsBus) for type compatibility,
|
||||
but calls MotorsBusBase.__init__ directly to skip the pyserial/deepdiff guards.
|
||||
"""
|
||||
|
||||
available_baudrates = [500_000, 1_000_000]
|
||||
default_timeout = 1000
|
||||
model_baudrate_table = DUMMY_MODEL_BAUDRATE_TABLE
|
||||
@@ -132,8 +139,13 @@ class MockMotorsBus(MotorsBus):
|
||||
normalized_data = ["Present_Position", "Goal_Position"]
|
||||
|
||||
def __init__(self, port: str, motors: dict[str, Motor]):
|
||||
super().__init__(port, motors)
|
||||
# Skip SerialMotorsBus.__init__ (which guards pyserial/deepdiff)
|
||||
# and call the base class directly — this mock never touches real serial.
|
||||
MotorsBusBase.__init__(self, port, motors)
|
||||
self.port_handler = MockPortHandler(port)
|
||||
self._id_to_model_dict = {m.id: m.model for m in self.motors.values()}
|
||||
self._id_to_name_dict = {m.id: name for name, m in self.motors.items()}
|
||||
self._model_nb_to_model_dict = {v: k for k, v in self.model_number_table.items()}
|
||||
|
||||
def _assert_protocol_is_compatible(self, instruction_name): ...
|
||||
def _handshake(self): ...
|
||||
|
||||
@@ -19,6 +19,7 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
pytest.importorskip("datasets", reason="datasets is required (install lerobot[dataset])")
|
||||
pytest.importorskip("deepdiff", reason="deepdiff is required (install lerobot[hardware])")
|
||||
|
||||
from lerobot.scripts.lerobot_calibrate import CalibrateConfig, calibrate
|
||||
from lerobot.scripts.lerobot_record import DatasetRecordConfig, RecordConfig, record
|
||||
|
||||
Reference in New Issue
Block a user