fancy_gym/test/test_custom_envs.py
2022-09-26 08:39:54 +02:00

36 lines
1.2 KiB
Python

import fancy_gym
import gym
import pytest
from test.utils import run_env, run_env_determinism
CUSTOM_IDS = [spec.id for spec in gym.envs.registry.all() if
"fancy_gym" in spec.entry_point and 'make_bb_env_helper' not in spec.entry_point]
SEED = 1
@pytest.mark.parametrize('env_id', CUSTOM_IDS)
def test_step_functionality(env_id: str):
"""Tests that step environments run without errors using random actions."""
run_env(env_id)
@pytest.mark.parametrize('env_id', CUSTOM_IDS)
def test_step_determinism(env_id: str):
"""Tests that for step environments identical seeds produce identical trajectories."""
seed = 0
run_env_determinism(env_id, seed)
@pytest.mark.parametrize('env_id', fancy_gym.ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS.values())
def test_bb_functionality(env_id: str):
"""Tests that black box environments run without errors using random actions."""
run_env(env_id)
@pytest.mark.parametrize('env_id', fancy_gym.ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS.values())
def test_bb_determinism(env_id: str):
"""Tests that for black box environment identical seeds produce identical trajectories."""
seed = 0
run_env_determinism(env_id, seed)