Skip to content

Commit

Permalink
Added test for VectorWrapper.metadata property
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSchneider42 committed Apr 10, 2024
1 parent f2e28b8 commit d980b9c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/vector/test_vector_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ def test_vector_env_wrapper_attributes():
assert np.allclose(wrapped.env.get_attr("gravity"), env.get_attr("gravity"))

env.close()


def test_vector_env_metadata():
"""Test if `metadata` property for VectorWrapper correctly forwards to the vector env it is wrapping."""
env = gym.make_vec("CartPole-v1", num_envs=3, vectorization_mode="sync")
wrapped = DummyVectorWrapper(
gym.make_vec("CartPole-v1", num_envs=3, vectorization_mode="sync")
)

assert env.metadata == wrapped.metadata
env.metadata = {"render_modes": ["rgb_array"]}
assert env.metadata != wrapped.metadata

env.close()

0 comments on commit d980b9c

Please sign in to comment.