Skip to content

Commit

Permalink
Test refactoring (#2427)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
RedTachyon authored Sep 28, 2021
1 parent ca42b05 commit 947b857
Show file tree
Hide file tree
Showing 56 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions scripts/generate_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import sys
import argparse

from gym.tests.envs.spec_list import should_skip_env_spec_for_tests
from gym.tests import generate_rollout_hash
from tests.envs.spec_list import should_skip_env_spec_for_tests
from tests import generate_rollout_hash

DATA_DIR = os.path.join(os.path.dirname(__file__), os.pardir, "gym", "envs", "tests")
ROLLOUT_STEPS = 100
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

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 = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

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 = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
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)
Expand Down
2 changes: 1 addition & 1 deletion gym/tests/envs/test_envs.py → tests/envs/test_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

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.utils.env_checker import check_env

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pytest
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__)
ROLLOUT_STEPS = 100
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

try:
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:
Box2D = None

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import numpy as np
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, arg1, arg2, arg3):

gym.register(
id="test.ArgumentEnv-v0",
entry_point="gym.tests.envs.test_registration:ArgumentEnv",
entry_point="tests.envs.test_registration:ArgumentEnv",
kwargs={
"arg1": "arg1",
"arg2": "arg2",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from multiprocessing import TimeoutError
from gym.spaces import Box, Tuple
from gym.error import AlreadyPendingCallError, NoAsyncCallError, ClosedEnvironmentError
from gym.tests.vector.utils import (
from tests.vector.utils import (
CustomSpace,
make_env,
make_slow_env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from gym.spaces import Tuple, Dict
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from gym.spaces import Tuple, Dict
from gym.error import CustomSpaceError
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 (
create_shared_memory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

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.sync_vector_env import SyncVectorEnv
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 947b857

Please sign in to comment.