Files
Gymnasium/tests/wrappers/test_human_rendering.py
Mark Towers 27f8e85051 Merge v1.0.0 (#682)
Co-authored-by: Kallinteris Andreas <30759571+Kallinteris-Andreas@users.noreply.github.com>
Co-authored-by: Jet <38184875+jjshoots@users.noreply.github.com>
Co-authored-by: Omar Younis <42100908+younik@users.noreply.github.com>
2023-11-07 13:27:25 +00:00

34 lines
891 B
Python

"""Test suite of HumanRendering wrapper."""
import re
import pytest
import gymnasium as gym
from gymnasium.wrappers import HumanRendering
def test_human_rendering():
for mode in ["rgb_array", "rgb_array_list"]:
env = HumanRendering(
gym.make("CartPole-v1", render_mode=mode, disable_env_checker=True)
)
assert env.render_mode == "human"
env.reset()
for _ in range(75):
_, _, terminated, truncated, _ = env.step(env.action_space.sample())
if terminated or truncated:
env.reset()
env.close()
env = gym.make("CartPole-v1", render_mode="human")
with pytest.raises(
AssertionError,
match=re.escape(
"Expected env.render_mode to be one of 'rgb_array' or 'rgb_array_list' but got 'human'"
),
):
HumanRendering(env)
env.close()