Skip to content

Commit

Permalink
test updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nissu99 authored and tpike3 committed Dec 9, 2024
1 parent 70a3f1f commit b05a3e7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/test_solara_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,15 @@ def __init__(self, **kwargs):
_check_model_params(ModelWithOnlyRequired.__init__, {})


# Test to check if params are arguments and keyword arguments
def test_check_model_params_with_both_args_and_kwargs():
"""Test that _check_model_params raises ValueError when both *args and **kwargs are present in model initialization."""

class ModelWithArgsAndKwargs:
def __init__(self, param1, *args, **kwargs):
#test that _check_model_params raises ValueError when *args are present
def test_check_model_params_with_args_only():
"""Test that _check_model_params raises ValueError when *args are present."""
class ModelWithArgsOnly:
def __init__(self, param1, *args):
pass

model_params = {"param1": 1}

with pytest.raises(
ValueError, match="Models with both \\*args and \\*\\*kwargs are not supported"
):
_check_model_params(ModelWithArgsAndKwargs.__init__, model_params)
with pytest.raises(ValueError, match= "Mesa's visualization requires the use of keyword arguments to ensure the parameters are passed to Solara correctly. Please ensure all model parameters are of form param=value"):
_check_model_params(ModelWithArgsOnly.__init__, model_params)

0 comments on commit b05a3e7

Please sign in to comment.