Files
Gymnasium/tests/wrappers/test_human_rendering.py
Mark Towers 799c8d20c1 Rename "rgb_array" to "rgb_array_list" and "single_rgb_array" to "rgb_array" (#3040)
* initial commit

* Fix CI

* Fixed CI

* third time the charm

* Fix mujoco environment render modes order

* Remove unnecessary changes

* pre-commit

* Fix tests

* Comment out test render modes

* Fix code review and readd mujoco

* pre-commit

* Fix testing envs

* Fix all GenericTestEnvs

* Do not run mujoco-py render environments
2022-09-01 09:06:42 -04:00

33 lines
828 B
Python

import re
import pytest
import gym
from gym.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()