-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
39 lines (30 loc) · 982 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
import unittest
import numpy as np
import gym
import gym_navops # noqa: F401
class TestNavOpsEnvironment(unittest.TestCase):
def setUp(self):
self._n = 2
self._env = gym.make('NavOps-v0')
self._env.reset()
self._mock = gym.make('NavOps-v0', mock=True)
def test_environment_space(self):
self.assertEqual(
self._env.observation_space.shape,
self._mock.observation_space.shape
)
self.assertEqual(
self._env.action_space.shape,
self._mock.action_space.shape
)
action = np.random.normal(0, 1, (self._n,)+self._env.action_space.shape)
obs, _, _, _ = self._env.step(action)
mobs, _, _, _ = self._mock.step(action)
self.assertEqual(obs.shape, mobs.shape)
def tearDown(self):
self._env.close()
self._mock.close()
if __name__ == "__main__":
unittest.main()