Skip to content

Commit 6877489

Browse files
committed
add test class TestParseParams
1 parent 0791056 commit 6877489

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

tests/test_concore.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,41 @@ def test_core_functions_exist(self):
8484

8585
assert callable(safe_literal_eval)
8686
assert callable(tryparam)
87-
assert callable(default_maxtime)
87+
assert callable(default_maxtime)
88+
89+
90+
class TestParseParams:
91+
92+
def test_simple_key_value_pairs(self):
93+
from concore import parse_params
94+
params = parse_params("a=1;b=2")
95+
assert params == {"a": 1, "b": 2}
96+
97+
def test_preserves_whitespace_in_values(self):
98+
from concore import parse_params
99+
params = parse_params("label = hello world ; x = 5")
100+
assert params["label"] == "hello world"
101+
assert params["x"] == 5
102+
103+
def test_embedded_equals_in_value(self):
104+
from concore import parse_params
105+
params = parse_params("url=https://example.com?a=1&b=2")
106+
assert params["url"] == "https://example.com?a=1&b=2"
107+
108+
def test_numeric_and_list_coercion(self):
109+
from concore import parse_params
110+
params = parse_params("delay=5;coeffs=[1,2,3]")
111+
assert params["delay"] == 5
112+
assert params["coeffs"] == [1, 2, 3]
113+
114+
def test_dict_literal_backward_compatibility(self):
115+
from concore import parse_params
116+
params = parse_params("{'a': 1, 'b': 2}")
117+
assert params == {"a": 1, "b": 2}
118+
119+
def test_windows_quoted_input(self):
120+
from concore import parse_params
121+
s = "\"a=1;b=2\""
122+
s = s[1:-1] # simulate quote stripping before parse_params
123+
params = parse_params(s)
124+
assert params == {"a": 1, "b": 2}

0 commit comments

Comments
 (0)