From d980b9c68094945de23934e4d9d21fad366fe28d Mon Sep 17 00:00:00 2001 From: Tim Schneider Date: Wed, 10 Apr 2024 17:05:02 +0200 Subject: [PATCH] Added test for VectorWrapper.metadata property --- tests/vector/test_vector_wrapper.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/vector/test_vector_wrapper.py b/tests/vector/test_vector_wrapper.py index 2701ecbb7..16dd82932 100644 --- a/tests/vector/test_vector_wrapper.py +++ b/tests/vector/test_vector_wrapper.py @@ -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()