Discard viewer object after render with close=True

Fixes #95
This commit is contained in:
Greg Brockman
2016-05-15 17:22:38 -07:00
parent 064f7377d9
commit 2ae0dbc846
13 changed files with 55 additions and 19 deletions

View File

@@ -10,13 +10,9 @@ from gym import envs
# This runs a smoketest on each official registered env. We may want
# to try also running environments which are not officially registered
# envs.
specs = [spec for spec in envs.registry.all()]
specs = [spec for spec in envs.registry.all() if spec._entry_point is not None]
@tools.params(*specs)
def test_env(spec):
# Skip for deprecated envs
if spec._entry_point is None:
return
# Skip mujoco tests for pull request CI
skip_mujoco = os.environ.get('TRAVIS_PULL_REQUEST', 'false') != 'false'
if skip_mujoco and spec._entry_point.startswith('gym.envs.mujoco:'):
@@ -38,7 +34,12 @@ def test_env(spec):
assert np.isscalar(reward), "{} is not a scalar for {}".format(reward, env)
assert isinstance(done, bool), "Expected {} to be a boolean".format(done)
for mode in env.metadata.get('render.modes'):
for mode in env.metadata.get('render.modes', []):
env.render(mode=mode)
env.render(close=True)
# Make sure we can render the environment after close.
for mode in env.metadata.get('render.modes', []):
env.render(mode=mode)
env.render(close=True)