diff --git a/munet/mutest/userapi.py b/munet/mutest/userapi.py index a904cec..4181b75 100644 --- a/munet/mutest/userapi.py +++ b/munet/mutest/userapi.py @@ -486,6 +486,9 @@ def _match_command_json( return expect_fail, {} try: + # Convert to string to validate the input is valid JSON + if not isinstance(match, str): + match = json.dumps(match) expect = json.loads(match) except Exception as error: expect = {} diff --git a/pyproject.toml b/pyproject.toml index 6399837..aaf5e21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "munet" -version = "0.13.15" +version = "0.13.16" description = "A package to facilitate network simulations" authors = ["Christian Hopps "] license = "GPL-2.0-or-later" diff --git a/tests/mutest/mutest_matchwait_json.py b/tests/mutest/mutest_matchwait_json.py index 23e05eb..2e84442 100644 --- a/tests/mutest/mutest_matchwait_json.py +++ b/tests/mutest/mutest_matchwait_json.py @@ -7,7 +7,7 @@ from munet.mutest.userapi import wait_step_json -js = step_json("r1", 'echo { "name": "chopps" }') +js = step_json("r1", """printf '{ "name": "chopps" }'""") log("SIMPLE JSON: %s", js) # expect passing tests @@ -201,7 +201,7 @@ json1 = '[{"foo":"foo"}]' json2 = '[{"foo":"foo"}, {"bar":"bar"}]' -json3 = '[{"bar":"bar"}, {"foo":"foo"}]' +json3 = [{"bar": "bar"}, {"foo": "foo"}] _, ret = match_step_json( "r1",