mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-19 13:32:03 +00:00
* Move tests to root with automatic PyCharm import refactoring. This will likely fail some tests * Changed entry point for a registration test env. * Move a stray lunar_lander test to tests/envs/... * black * Change the version from which importlib_metadata is replaced with importlib.metadata. Also requiring installing importlib_metadata for python 3.8 now. ??????????? * Undo last commit
25 lines
494 B
Python
25 lines
494 B
Python
from gym.utils.closer import Closer
|
|
|
|
|
|
class Closeable(object):
|
|
close_called = False
|
|
|
|
def close(self):
|
|
self.close_called = True
|
|
|
|
|
|
def test_register_unregister():
|
|
registry = Closer(atexit_register=False)
|
|
c1 = Closeable()
|
|
c2 = Closeable()
|
|
|
|
assert not c1.close_called
|
|
assert not c2.close_called
|
|
registry.register(c1)
|
|
id2 = registry.register(c2)
|
|
|
|
registry.unregister(id2)
|
|
registry.close()
|
|
assert c1.close_called
|
|
assert not c2.close_called
|