mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-20 22:12:03 +00:00
33 lines
852 B
Python
33 lines
852 B
Python
import re
|
|
|
|
import pytest
|
|
|
|
import gymnasium
|
|
from gymnasium.wrappers import HumanRendering
|
|
|
|
|
|
def test_human_rendering():
|
|
for mode in ["rgb_array", "rgb_array_list"]:
|
|
env = HumanRendering(
|
|
gymnasium.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 = gymnasium.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()
|