def test_does_not_modify_action(self): env = PointEnv() a = env.action_space.sample() a_copy = a.copy() env.reset() env.step(a) self.assertEquals(a.all(), a_copy.all())
def test_visualization(self): env = PointEnv() assert env.render_modes == ['ascii'] env.reset() assert env.render('ascii') == f'Point: {env._point}, Goal: {env._goal}' env.visualize() env.step(env.action_space.sample())
def test_does_not_modify_action(self): env = PointEnv() a = env.action_space.sample() a_copy = a.copy() env.reset() env.step(a) assert a.all() == a_copy.all() env.close()
def test_reset(self): env = PointEnv() env.reset() assert (env._point == np.array([0, 0])).all() a = env.action_space.sample() env.step(a) env.reset() assert (env._point == np.array([0, 0])).all()
def test_observation_space(self): env = PointEnv() env.reset() obs_space = env.observation_space a = env.action_space.sample() obs = env.step(a).observation assert obs_space.contains(obs)
def test_done(self): env = PointEnv() for _ in range(1000): _, _, done, _ = env.step(env._goal) if done: break else: assert False, 'Should report done'
def test_done(self): env = PointEnv() env.reset() for _ in range(1000): done = env.step(env._goal).terminal if done: break else: assert False, 'Should report done'
def test_catch_no_reset(self): env = PointEnv() with pytest.raises(RuntimeError, match='reset()'): env.step(env.action_space.sample())