diff --git a/hathor/sysctl/runner.py b/hathor/sysctl/runner.py index ef75a21b6..6ee32cb7b 100644 --- a/hathor/sysctl/runner.py +++ b/hathor/sysctl/runner.py @@ -76,7 +76,7 @@ def deserialize(self, value_str: str) -> Any: if len(value_str) == 0: return () - parts = [x.strip() for x in value_str.split(',')] + parts = json.loads(f'[{value_str}]') if len(parts) > 1: - return tuple(json.loads(x) for x in parts) + return tuple(parts) return json.loads(value_str) diff --git a/tests/sysctl/test_runner.py b/tests/sysctl/test_runner.py new file mode 100644 index 000000000..e4d1c6806 --- /dev/null +++ b/tests/sysctl/test_runner.py @@ -0,0 +1,31 @@ + +import pytest + +from hathor.sysctl import Sysctl +from hathor.sysctl.runner import SysctlRunner + + +@pytest.mark.parametrize( + 'args', + [ + 'string', + "\"", + 1, + True, + False, + 'a,b', + (1, 2, 3), + (1, 'string', True), + [1, 2, 3], + (1, [1, 2, 3]), + (1, ["a,a,a", "b", "c"]), + ] +) +def test_deserialize(args): + root = Sysctl() + runner = SysctlRunner(root) + + args_serialized = runner.serialize(args) + args_deserialized = runner.deserialize(args_serialized) + + assert args == args_deserialized