Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing raise. #1031

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gymnasium/envs/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _check_can_jsonify(env_spec: dict[str, Any]):

for key, value in env_spec.items():
if callable(value):
ValueError(
raise ValueError(
f"Callable found in {spec_name} for {key} attribute with value={value}. Currently, Gymnasium does not support serialising callables."
)

Expand Down
15 changes: 15 additions & 0 deletions tests/envs/registration/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,18 @@ def test_spec_default_lookups():

assert gym.spec("test/TestEnv") is not None
del gym.registry["test/TestEnv"]


def test_check_can_jsonify():
def no_entry_point():
pass

gym.register(id="test/TestEnv-v0", entry_point=no_entry_point)
with pytest.raises(
ValueError,
match="^Callable found in test/TestEnv-v0 for entry_point attribute "
"with value=<.*>. Currently, Gymnasium does not support "
"serialising callables.$",
):
gym.spec("test/TestEnv-v0").to_json()
del gym.registry["test/TestEnv-v0"]
Loading