diff --git a/tests/test_motors.py b/tests/test_motors.py index dfdb3318..372016e3 100644 --- a/tests/test_motors.py +++ b/tests/test_motors.py @@ -9,7 +9,6 @@ pytest -sx tests/test_motors.py::test_find_port pytest -sx tests/test_motors.py::test_motors_bus ``` - Example of running test on real dynamixel motors connected to the computer: ```bash pytest -sx tests/test_motors.py::test_motors_bus[dynamixel] diff --git a/tests/test_robots.py b/tests/test_robots.py index 4ce3805e..9dbcc540 100644 --- a/tests/test_robots.py +++ b/tests/test_robots.py @@ -1,10 +1,27 @@ """ -Tests meant to be used locally and launched manually. +Tests for physical robots and their mocked versions. +If the physical robots are not connected to the computer, or not working, +the test will be skipped. -Example usage: +Example of running a specific test: ```bash pytest -sx tests/test_robots.py::test_robot ``` + +Example of running test on real robots connected to the computer: +```bash +pytest -sx tests/test_robots.py::test_robot[koch] +pytest -sx tests/test_robots.py::test_robot[koch_bimanual] +pytest -sx tests/test_robots.py::test_robot[aloha] +``` + +Example of running test on a mocked version of robots: +```bash +pytest -sx -k "mocked_koch" tests/test_robots.py::test_robot +pytest -sx -k "mocked_koch_bimanual" tests/test_robots.py::test_robot +pytest -sx -k "mocked_aloha" tests/test_robots.py::test_robot +``` + """ from pathlib import Path @@ -12,12 +29,11 @@ from pathlib import Path import pytest import torch -from lerobot import available_robots from lerobot.common.robot_devices.robots.factory import make_robot as make_robot_from_cfg from lerobot.common.robot_devices.robots.utils import Robot from lerobot.common.robot_devices.utils import RobotDeviceAlreadyConnectedError, RobotDeviceNotConnectedError from lerobot.common.utils.utils import init_hydra_config -from tests.utils import ROBOT_CONFIG_PATH_TEMPLATE, require_robot +from tests.utils import ROBOT_CONFIG_PATH_TEMPLATE, TEST_ROBOT_TYPES, require_robot def make_robot(robot_type: str, overrides: list[str] | None = None) -> Robot: @@ -27,7 +43,7 @@ def make_robot(robot_type: str, overrides: list[str] | None = None) -> Robot: return robot -@pytest.mark.parametrize("robot_type", available_robots) +@pytest.mark.parametrize("robot_type", TEST_ROBOT_TYPES) @require_robot def test_robot(tmpdir, request, robot_type): # TODO(rcadene): measure fps in nightly? diff --git a/tests/utils.py b/tests/utils.py index 433be47d..c7915ea2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -197,6 +197,13 @@ def require_robot(func): mock_cameras(request) mock_motors(request) + def mock_input(text): + print(text) + + monkeypatch = request.getfixturevalue("monkeypatch") + # To run calibration without user input + monkeypatch.setattr("builtins.input", mock_input) + # Run test with a real robot. Skip test if robot connection fails. else: # `is_robot_available` is defined in `tests/conftest.py`