Skip to content

Commit

Permalink
Add gymnasium env duration requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
AOS55 committed May 25, 2024
1 parent f2655f1 commit fc0a13b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/envs/test_gym.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import gymnasium as gym
import pytest

import flyer_env

# flyer_env.register_flyer_envs()
from flyer_env.envs.flyer_env import FlyerEnv

envs = ["flyer-v1",
"trajectory-v1",
Expand All @@ -16,16 +14,24 @@
def test_env_step(env_spec):
env = gym.make(env_spec)

obs, info = env.reset()
obs, _ = env.reset()
assert env.observation_space.contains(obs)

terminated = truncated = False
while not (terminated or truncated):
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
obs, _, terminated, truncated, _ = env.step(action)
assert env.observation_space.contains(obs)
env.close()

def test_env_reset_options(env_spec: str = "flyer-v1"):
env = gym.make(env_spec)
# TODO: test all env reset options

# Might want to add some more parameters to test here

default_duration = FlyerEnv().default_config()["duration"]
assert env.unwrapped.config["duration"] == default_duration

update_duration = default_duration * 2
env.reset(options={"config": {"duration": update_duration}})
assert env.unwrapped.config["duration"] == update_duration

0 comments on commit fc0a13b

Please sign in to comment.