From 177c1b62e9e2924cb09f3b1e61c20dd28b2c250a Mon Sep 17 00:00:00 2001 From: Kallinteris Andreas Date: Fri, 27 Sep 2024 13:35:03 +0300 Subject: [PATCH] simplify test --- tests/envs/mujoco/test_mujoco_rendering.py | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/envs/mujoco/test_mujoco_rendering.py b/tests/envs/mujoco/test_mujoco_rendering.py index 6740e220b..ee2f7b627 100644 --- a/tests/envs/mujoco/test_mujoco_rendering.py +++ b/tests/envs/mujoco/test_mujoco_rendering.py @@ -84,19 +84,12 @@ def test_max_geom_attribute( viewer.close() -def test_camera_id(): +@pytest.mark.parametrize("render_mode", ["human", "rgb_array", "depth_array"]) +def test_camera_id(render_mode: str): """Assert that the camera_id parameter works correctly.""" - env_a = gymnasium.make("Ant-v5", camera_id=0, render_mode="rgb_array").unwrapped - env_b = gymnasium.make("Ant-v5", camera_id=0, render_mode="rgb_array").unwrapped - env_c = gymnasium.make("Ant-v5", camera_id=1, render_mode="rgb_array").unwrapped - - env_a.reset(seed=5) - env_b.reset(seed=5) - env_c.reset(seed=5) - - assert ( - env_a.render() == env_b.render() - ).all(), "If this fails, the test is not valid" - assert ( - env_a.render() != env_c.render() - ).all(), "render() output should be different for different camera_id" + env_a = gymnasium.make("Ant-v5", camera_id=0, render_mode=render_mode).unwrapped + env_b = gymnasium.make("Ant-v5", camera_id=0, render_mode=render_mode).unwrapped + env_c = gymnasium.make("Ant-v5", camera_id=1, render_mode=render_mode).unwrapped + + assert env_a.mujoco_renderer.camera_id == env_b.mujoco_renderer.camera_id + assert env_a.mujoco_renderer.camera_id != env_c.mujoco_renderer.camera_id