Test refactoring (#2427)

* Move tests to root with automatic PyCharm import refactoring. This will likely fail some tests

* Changed entry point for a registration test env.

* Move a stray lunar_lander test to tests/envs/...

* black

* Change the version from which importlib_metadata is replaced with importlib.metadata. Also requiring installing importlib_metadata for python 3.8 now.

???????????

* Undo last commit
This commit is contained in:
Ariel Kwiatkowski
2021-09-29 01:53:30 +02:00
committed by GitHub
parent ca42b05243
commit 947b857bd4
56 changed files with 21 additions and 17 deletions

View File

@@ -4,8 +4,8 @@ import os
import sys import sys
import argparse import argparse
from gym.tests.envs.spec_list import should_skip_env_spec_for_tests from tests.envs.spec_list import should_skip_env_spec_for_tests
from gym.tests import generate_rollout_hash from tests import generate_rollout_hash
DATA_DIR = os.path.join(os.path.dirname(__file__), os.pardir, "gym", "envs", "tests") DATA_DIR = os.path.join(os.path.dirname(__file__), os.pardir, "gym", "envs", "tests")
ROLLOUT_STEPS = 100 ROLLOUT_STEPS = 100

View File

@@ -3,7 +3,7 @@ import pickle
import pytest import pytest
from gym import envs from gym import envs
from gym.tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE from tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
ENVIRONMENT_IDS = ( ENVIRONMENT_IDS = (

View File

@@ -3,7 +3,7 @@ import pickle
import pytest import pytest
from gym import envs from gym import envs
from gym.tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE from tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
ENVIRONMENT_IDS = ( ENVIRONMENT_IDS = (

View File

@@ -3,7 +3,7 @@ import pickle
import pytest import pytest
from gym import envs from gym import envs
from gym.tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE from tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
@pytest.mark.skipif(skip_mujoco, reason=SKIP_MUJOCO_WARNING_MESSAGE) @pytest.mark.skipif(skip_mujoco, reason=SKIP_MUJOCO_WARNING_MESSAGE)

View File

@@ -1,7 +1,7 @@
import numpy as np import numpy as np
import pytest import pytest
from gym.tests.envs.spec_list import spec_list from tests.envs.spec_list import spec_list
@pytest.mark.parametrize("spec", spec_list) @pytest.mark.parametrize("spec", spec_list)

View File

@@ -2,7 +2,7 @@ import pytest
import numpy as np import numpy as np
from gym import envs from gym import envs
from gym.tests.envs.spec_list import spec_list from tests.envs.spec_list import spec_list
from gym.spaces import Box from gym.spaces import Box
from gym.utils.env_checker import check_env from gym.utils.env_checker import check_env

View File

@@ -10,7 +10,7 @@ import os
import pytest import pytest
from gym import spaces, logger from gym import spaces, logger
from gym.tests.envs.spec_list import spec_list from tests.envs.spec_list import spec_list
DATA_DIR = os.path.dirname(__file__) DATA_DIR = os.path.dirname(__file__)
ROLLOUT_STEPS = 100 ROLLOUT_STEPS = 100

View File

@@ -2,7 +2,11 @@ import pytest
try: try:
import Box2D import Box2D
from .lunar_lander import LunarLander, LunarLanderContinuous, demo_heuristic_lander from gym.envs.box2d.lunar_lander import (
LunarLander,
LunarLanderContinuous,
demo_heuristic_lander,
)
except ImportError: except ImportError:
Box2D = None Box2D = None

View File

@@ -1,7 +1,7 @@
import unittest import unittest
import numpy as np import numpy as np
from gym import envs from gym import envs
from gym.tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE from tests.envs.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
def verify_environments_match( def verify_environments_match(

View File

@@ -14,7 +14,7 @@ class ArgumentEnv(gym.Env):
gym.register( gym.register(
id="test.ArgumentEnv-v0", id="test.ArgumentEnv-v0",
entry_point="gym.tests.envs.test_registration:ArgumentEnv", entry_point="tests.envs.test_registration:ArgumentEnv",
kwargs={ kwargs={
"arg1": "arg1", "arg1": "arg1",
"arg2": "arg2", "arg2": "arg2",

View File

@@ -4,7 +4,7 @@ import numpy as np
from multiprocessing import TimeoutError from multiprocessing import TimeoutError
from gym.spaces import Box, Tuple from gym.spaces import Box, Tuple
from gym.error import AlreadyPendingCallError, NoAsyncCallError, ClosedEnvironmentError from gym.error import AlreadyPendingCallError, NoAsyncCallError, ClosedEnvironmentError
from gym.tests.vector.utils import ( from tests.vector.utils import (
CustomSpace, CustomSpace,
make_env, make_env,
make_slow_env, make_slow_env,

View File

@@ -5,7 +5,7 @@ from collections import OrderedDict
from gym.spaces import Tuple, Dict from gym.spaces import Tuple, Dict
from gym.vector.utils.spaces import _BaseGymSpaces from gym.vector.utils.spaces import _BaseGymSpaces
from gym.tests.vector.utils import spaces from tests.vector.utils import spaces
from gym.vector.utils.numpy_utils import concatenate, create_empty_array from gym.vector.utils.numpy_utils import concatenate, create_empty_array

View File

@@ -9,7 +9,7 @@ from collections import OrderedDict
from gym.spaces import Tuple, Dict from gym.spaces import Tuple, Dict
from gym.error import CustomSpaceError from gym.error import CustomSpaceError
from gym.vector.utils.spaces import _BaseGymSpaces from gym.vector.utils.spaces import _BaseGymSpaces
from gym.tests.vector.utils import spaces, custom_spaces from tests.vector.utils import spaces, custom_spaces
from gym.vector.utils.shared_memory import ( from gym.vector.utils.shared_memory import (
create_shared_memory, create_shared_memory,

View File

@@ -2,7 +2,7 @@ import pytest
import numpy as np import numpy as np
from gym.spaces import Box, MultiDiscrete, Tuple, Dict from gym.spaces import Box, MultiDiscrete, Tuple, Dict
from gym.tests.vector.utils import spaces, custom_spaces, CustomSpace from tests.vector.utils import spaces, custom_spaces, CustomSpace
from gym.vector.utils.spaces import batch_space from gym.vector.utils.spaces import batch_space

View File

@@ -2,7 +2,7 @@ import pytest
import numpy as np import numpy as np
from gym.spaces import Box, Tuple from gym.spaces import Box, Tuple
from gym.tests.vector.utils import CustomSpace, make_env, make_custom_space_env from tests.vector.utils import CustomSpace, make_env, make_custom_space_env
from gym.vector.sync_vector_env import SyncVectorEnv from gym.vector.sync_vector_env import SyncVectorEnv

View File

@@ -2,7 +2,7 @@ import pytest
import numpy as np import numpy as np
from gym.spaces import Tuple from gym.spaces import Tuple
from gym.tests.vector.utils import CustomSpace, make_env from tests.vector.utils import CustomSpace, make_env
from gym.vector.async_vector_env import AsyncVectorEnv from gym.vector.async_vector_env import AsyncVectorEnv
from gym.vector.sync_vector_env import SyncVectorEnv from gym.vector.sync_vector_env import SyncVectorEnv