From b647b0c95d823a294ac5da6c15d5daad41874e1c Mon Sep 17 00:00:00 2001 From: Xukai Wang Date: Fri, 13 Feb 2026 03:03:49 +0800 Subject: [PATCH] support/testing: add python-gymnasium tests Add a basic runtime test for the python-gymnasium package. This test verifies the fundamental operations of the library by: - Importing `gymnasium`. - Creating a "CartPole-v1" environment. - Resetting the environment. - Taking a random action step. - Closing the environment. Signed-off-by: Xukai Wang [Julien: - sort DEVELOPERS entries alphabetically - fix file name typo in DEVELOPERS - remove selection of dependencies in test config ] Signed-off-by: Julien Olivain --- DEVELOPERS | 2 ++ .../testing/tests/package/sample_python_gymnasium.py | 8 ++++++++ .../testing/tests/package/test_python_gymnasium.py | 12 ++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 support/testing/tests/package/sample_python_gymnasium.py create mode 100644 support/testing/tests/package/test_python_gymnasium.py diff --git a/DEVELOPERS b/DEVELOPERS index f0aadbbcd3..410073d48a 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -3485,8 +3485,10 @@ F: package/python-farama-notifications/ F: package/python-gymnasium/ F: support/testing/tests/package/sample_python_cloudpickle.py F: support/testing/tests/package/sample_python_farama_notifications.py +F: support/testing/tests/package/sample_python_gymnasium.py F: support/testing/tests/package/test_python_cloudpickle.py F: support/testing/tests/package/test_python_farama_notifications.py +F: support/testing/tests/package/test_python_gymnasium.py N: Yair Ben Avraham F: package/casync/ diff --git a/support/testing/tests/package/sample_python_gymnasium.py b/support/testing/tests/package/sample_python_gymnasium.py new file mode 100644 index 0000000000..42997b2982 --- /dev/null +++ b/support/testing/tests/package/sample_python_gymnasium.py @@ -0,0 +1,8 @@ +import gymnasium as gym +env = gym.make("CartPole-v1") + +observation, info = env.reset() +random_action = env.action_space.sample() +next_observation, reward, terminated, truncated, info = env.step(random_action) + +env.close() diff --git a/support/testing/tests/package/test_python_gymnasium.py b/support/testing/tests/package/test_python_gymnasium.py new file mode 100644 index 0000000000..c36ce37dde --- /dev/null +++ b/support/testing/tests/package/test_python_gymnasium.py @@ -0,0 +1,12 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3Gymnasium(TestPythonPackageBase): + __test__ = True + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_GYMNASIUM=y + """ + sample_scripts = ["tests/package/sample_python_gymnasium.py"] + timeout = 20