diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a113471..b395378f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,4 +43,4 @@ jobs: - name: Install evolution gym run: pip install -e . - name: Run test - run: xvfb-run python -m pytest -s -v tests/screen_free/test_img_render_modes.py + run: xvfb-run python -m pytest -s -v -n auto -m lite diff --git a/pytest.ini b/pytest.ini index 61acd0d2..310d7672 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,4 @@ [pytest] -addopts = --ignore=examples/externals --ignore=evogym/simulator/externals --ignore=evogym/examples/gym_test.py \ No newline at end of file +addopts = --ignore=examples/externals --ignore=evogym/simulator/externals --ignore=evogym/examples/gym_test.py +markers = + lite: mark as part of the lite test suite \ No newline at end of file diff --git a/tests/requires_screen/test_screen_render_modes.py b/tests/requires_screen/test_screen_render_modes.py index 5166209f..56583340 100644 --- a/tests/requires_screen/test_screen_render_modes.py +++ b/tests/requires_screen/test_screen_render_modes.py @@ -7,6 +7,13 @@ import evogym.envs from evogym import sample_robot +LITE_TEST_ENV_NAMES = [ + "Pusher-v0", + "Walker-v0", + "Traverser-v0", +] + +@pytest.mark.lite @pytest.mark.parametrize( "render_mode, add_options", list(product( @@ -41,9 +48,15 @@ def test_render_modes(render_mode, add_options): ob, reward, terminated, truncated, info = env.step(action) env.close() - -# @pytest.mark.parametrize("env_name", evogym.BASELINE_ENV_NAMES) -@pytest.mark.parametrize("env_name", ["ObstacleTraverser-v1", "Traverser-v0"]) + +def get_all_env_render_params(): + return [ + env_name if env_name not in LITE_TEST_ENV_NAMES + else pytest.param(env_name, marks=pytest.mark.lite) + for env_name in evogym.BASELINE_ENV_NAMES + ] + +@pytest.mark.parametrize("env_name", get_all_env_render_params()) def test_all_env_render(env_name): """ - Env can render to screen diff --git a/tests/screen_free/test_baseline_envs.py b/tests/screen_free/test_baseline_envs.py index cc08f4ca..1550a19a 100644 --- a/tests/screen_free/test_baseline_envs.py +++ b/tests/screen_free/test_baseline_envs.py @@ -5,7 +5,20 @@ import evogym.envs from evogym import sample_robot -@pytest.mark.parametrize("env_name", evogym.BASELINE_ENV_NAMES) +LITE_TEST_ENV_NAMES = [ + "Pusher-v0", + "Walker-v0", + "Traverser-v0", +] + +def get_params(): + return [ + env_name if env_name not in LITE_TEST_ENV_NAMES + else pytest.param(env_name, marks=pytest.mark.lite) + for env_name in evogym.BASELINE_ENV_NAMES + ] + +@pytest.mark.parametrize("env_name", get_params()) def test_env_creatable_and_has_correct_api(env_name): """ - Env is creatable diff --git a/tests/screen_free/test_img_render_modes.py b/tests/screen_free/test_img_render_modes.py index 83c95e9b..b42e1e4e 100644 --- a/tests/screen_free/test_img_render_modes.py +++ b/tests/screen_free/test_img_render_modes.py @@ -7,20 +7,25 @@ import evogym.envs from evogym import sample_robot -# @pytest.mark.parametrize( -# "env_name, render_mode", -# list(product( -# evogym.BASELINE_ENV_NAMES, -# [None, "img", "rgb_array"], -# )) -# ) -@pytest.mark.parametrize( - "env_name, render_mode", - list(product( - ["ObstacleTraverser-v1", "Traverser-v0"], +LITE_TEST_ENV_NAMES = [ + "Pusher-v0", + "Walker-v0", + "Traverser-v0", +] + +def get_params(): + params = product( + evogym.BASELINE_ENV_NAMES, [None, "img", "rgb_array"], - )) -) + ) + return [ + param if param[0] not in LITE_TEST_ENV_NAMES + else pytest.param(*param, marks=pytest.mark.lite) + for param in params + ] + + +@pytest.mark.parametrize("env_name, render_mode", get_params()) def test_render(env_name, render_mode): """ - Env can render to none and to image diff --git a/tests/screen_free/test_utils.py b/tests/screen_free/test_utils.py index 38315cc9..481d0963 100644 --- a/tests/screen_free/test_utils.py +++ b/tests/screen_free/test_utils.py @@ -1,4 +1,5 @@ import numpy as np +import pytest from pytest import raises from typing import List, Tuple @@ -8,6 +9,7 @@ is_connected, has_actuator, get_full_connectivity ) +@pytest.mark.lite def test_get_uniform(): ones = get_uniform(1) assert np.allclose(ones, np.ones(1)), ( @@ -18,7 +20,8 @@ def test_get_uniform(): assert np.allclose(one_thirds, np.ones(3) / 3), ( f"Expected {np.ones(3) / 3}, got {one_thirds}" ) - + +@pytest.mark.lite def test_draw(): result = draw([0.2]) assert result == 0, f"Expected 0, got {result}" @@ -38,7 +41,8 @@ def test_draw(): for i in range(10): result = draw(pd) assert result in list(range(10)), f"Expected result to be between 0 and 9, got {result}" - + +@pytest.mark.lite def test_has_actuator(): h_act, v_act = VOXEL_TYPES['H_ACT'], VOXEL_TYPES['V_ACT'] others = [ @@ -109,7 +113,8 @@ def test_is_connected(): [empty, others[1], others[0]] ]) assert not is_connected(robot), "Expected not connected" - + +@pytest.mark.lite def test_get_full_connectivity(): empty = VOXEL_TYPES['EMPTY'] others = [ @@ -157,7 +162,7 @@ def connections_contains_all(connections: np.ndarray, expected: List[Tuple[int, assert connections.shape[0] == 2, "Expected 2" connections_contains_all(connections, [(0, 1), (1, 4), (4, 5)]) - +@pytest.mark.lite def test_sample_robot(): h_act, v_act, empty = VOXEL_TYPES['H_ACT'], VOXEL_TYPES['V_ACT'], VOXEL_TYPES['EMPTY'] diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 00000000..53b1b913 --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,5 @@ +LITE_TEST_ENV_NAMES = [ + "Pusher-v0", + "Walker-v0", + "Traverser-v0", +] \ No newline at end of file