mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-09-02 10:35:52 +00:00
* Improve auto close implementation - Register all envs at initialization time, not just ones created via make - Simplify names and add more documentation on interface - Move closer instances into the relevant modules review-requested: @jietang * Close environments in the tests This isn't strictly needed, but means there are fewer Doom subprocesses hanging around while the tests run. * Use 4 space indent in comment * Improve docstrings in core * Don't pass through args to __new__ The __init__ method gets called once __new__ returns, so these arguments are either ignored (Python 2) or result in an error (Python 3). The __init__ method automatically gets called with the correct arguments. * Fixup comments
34 lines
898 B
Python
34 lines
898 B
Python
import numpy as np
|
|
from nose2 import tools
|
|
import os
|
|
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
|
|
from gym import envs
|
|
from gym.monitoring.tests import helpers
|
|
|
|
specs = [spec for spec in envs.registry.all() if spec._entry_point is not None]
|
|
@tools.params(*specs)
|
|
def test_renderable_after_monitor_close(spec):
|
|
# TODO(gdb 2016-05-15): Re-enable these tests after fixing box2d-py
|
|
if spec._entry_point.startswith('gym.envs.box2d:'):
|
|
logger.warn("Skipping tests for box2d env {}".format(spec._entry_point))
|
|
return
|
|
|
|
with helpers.tempdir() as temp:
|
|
env = spec.make()
|
|
# Skip un-renderable envs
|
|
if 'human' not in env.metadata.get('render.modes', []):
|
|
return
|
|
|
|
env.monitor.start(temp)
|
|
env.reset()
|
|
env.monitor.close()
|
|
|
|
env.reset()
|
|
env.render()
|
|
env.render(close=True)
|
|
|
|
env.close()
|