Fix play assertion error (#132)

This commit is contained in:
Markus Krimmel
2022-11-16 13:12:35 +01:00
committed by GitHub
parent a13b9c40fe
commit 92d3fa3e71
2 changed files with 10 additions and 2 deletions

View File

@@ -51,7 +51,7 @@ class PlayableGame:
zoom: If to zoom in on the environment render
"""
if env.render_mode not in {"rgb_array", "rgb_array_list"}:
logger.error(
raise ValueError(
"PlayableGame wrapper works only with rgb_array and rgb_array_list render modes, "
f"but your environment render_mode = {env.render_mode}."
)

View File

@@ -206,4 +206,12 @@ def test_play_loop_real_env():
def test_play_no_keys():
with pytest.raises(MissingKeysToAction):
play(gym.make("CartPole-v1"))
play(gym.make("CartPole-v1", render_mode="rgb_array"))
def test_wrong_render_mode():
with pytest.raises(
ValueError,
match=r"PlayableGame wrapper works only with rgb_array and rgb_array_list render modes",
):
play(gym.make("CartPole-v1"), keys_to_action={})