code: def test_render_modes(spec):
      """There is a known issue where rendering a mujoco environment then mujoco-py will cause an error on non-mac based systems.
  
      Therefore, we are only testing with mujoco environments.
      """
      env = spec.make()
  
      assert "rgb_array" in env.metadata["render_modes"]
      assert "human" in env.metadata["render_modes"]
  
      for mode in env.metadata["render_modes"]:
          if mode != "human":
              new_env = spec.make(render_mode=mode)
  
              new_env.reset()
              rendered = new_env.render()
              check_rendered(rendered, mode)
  
              new_env.step(new_env.action_space.sample())
              rendered = new_env.render()
              check_rendered(rendered, mode)
  
              new_env.close()
      env.close()
  
file_path: gym/tests/envs/test_envs.py
imports: import pickle
  import warnings
  import numpy
  import pytest
  import gym
  from gym.envs.registration import EnvSpec
  from gym.logger import warn
  from gym.utils.env_checker import check_env, data_equivalence
  from tests.envs.utils import all_testing_env_specs, all_testing_initialised_envs, assert_equals
label_desc: Use image node_id 4 for calling a global function with example usage: test_render_modes(spec) without return types