class TestAbstractMethods(unittest.TestCase): """ These series of tests are meant to ensure that the environment abstractions exist and are in fact abstract, i.e. they will raise errors if not implemented in a child class. """ def setUp(self): env, scenario = ring_road_exp_setup() sim_params = SumoParams() # FIXME: make ambiguous env_params = EnvParams() self.env = Env(sim_params=sim_params, env_params=env_params, scenario=scenario) def tearDown(self): self.env.terminate() self.env = None def test_get_state(self): """Checks that get_state raises an error.""" self.assertRaises(NotImplementedError, self.env.get_state) def test_compute_reward(self): """Checks that compute_reward returns 0.""" self.assertEqual(self.env.compute_reward([]), 0) def test__apply_rl_actions(self): self.assertRaises(NotImplementedError, self.env._apply_rl_actions, rl_actions=None)
class TestAbstractMethods(unittest.TestCase): """ These series of tests are meant to ensure that the environment abstractions exist and are in fact abstract, i.e. they will raise errors if not implemented in a child class. """ def setUp(self): env, scenario = ring_road_exp_setup() sumo_params = SumoParams() env_params = EnvParams() self.env = Env(sumo_params=sumo_params, env_params=env_params, scenario=scenario) def tearDown(self): self.env.terminate() self.env = None def test_get_state(self): """Checks that get_state raises an error.""" try: self.env.get_state() raise AssertionError except NotImplementedError: return def test_action_space(self): try: self.env.action_space raise AssertionError except NotImplementedError: return def test_observation_space(self): try: self.env.observation_space raise AssertionError except NotImplementedError: return def test_compute_reward(self): """Checks that compute_reward returns 0.""" self.assertEqual(self.env.compute_reward([]), 0) def test__apply_rl_actions(self): try: self.env._apply_rl_actions(None) raise AssertionError except NotImplementedError: return