swpark5 commited on
Commit
896d8d7
·
1 Parent(s): c3efe87

Test: 환경 테스트를 위한 테스트 코드 추가

Browse files

test_env.py는 env.py가 제대로 환경을 생성하는지 테스트합니다. WSL
환경에서는 n_envs=2 테스트를 통과하지 못할 수 있습니다.

Files changed (2) hide show
  1. __pycache__/env.cpython-310.pyc +0 -0
  2. test_env.py +37 -0
__pycache__/env.cpython-310.pyc ADDED
Binary file (3.17 kB). View file
 
test_env.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from env import make_env
3
+
4
+ print("Testing local make_env function...")
5
+
6
+ # 1. n_envs=1 (단일 환경) 테스트
7
+ print("Testing with n_envs=1...")
8
+ env_vec_n1 = make_env(n_envs=1, use_async_envs=False)
9
+ obs, info = env_vec_n1.reset()
10
+
11
+ print(f" Reset OK. Observation shape (n_envs=1): {obs.shape}")
12
+ assert obs.shape == (1, 12) # (n_envs, obs_shape)
13
+
14
+ action = env_vec_n1.action_space.sample()
15
+ obs, _, _, _, _ = env_vec_n1.step(action)
16
+ print(f" Step OK. Observation shape (n_envs=1): {obs.shape}")
17
+ assert obs.shape == (1, 12)
18
+ env_vec_n1.close()
19
+ print(" n_envs=1 Test Passed.")
20
+
21
+
22
+ # 2. n_envs=2 (병렬 환경) 테스트
23
+ print("\nTesting with n_envs=2...")
24
+ env_vec_n2 = make_env(n_envs=2, use_async_envs=False)
25
+ obs, info = env_vec_n2.reset()
26
+
27
+ print(f" Reset OK. Observation shape (n_envs=2): {obs.shape}")
28
+ assert obs.shape == (2, 12) # (n_envs, obs_shape)
29
+
30
+ action = env_vec_n2.action_space.sample()
31
+ obs, _, _, _, _ = env_vec_n2.step(action)
32
+ print(f" Step OK. Observation shape (n_envs=2): {obs.shape}")
33
+ assert obs.shape == (2, 12)
34
+ env_vec_n2.close()
35
+ print(" n_envs=2 Test Passed.")
36
+
37
+ print("\n--- All local tests passed! ---")