def test_combine_batch_params_glob(tmpdir): tmpdir = str(tmpdir) create_tree(tmpdir, {"aaa": "a", "subdir": {"b": "b", "c": "c"}}) with chpwd(tmpdir): res = sorted(_combine_batch_params(["foo=a*,subdir/*,other"]), key=lambda d: d["foo"]) assert list(res) == [ {"foo": "aaa"}, {"foo": "other"}, {"foo": "subdir/b"}, {"foo": "subdir/c"}]
def test_combine_batch_params_no_equal(): with pytest.raises(ValueError): list(_combine_batch_params(["a"]))
def test_combine_batch_params_repeat_key(): with pytest.raises(ValueError): list(_combine_batch_params(["a=1", "a=2"]))
def test_combine_batch_params(params, expected): actual = list(sorted(_combine_batch_params(params), key=lambda d: (d.get("a"), d.get("b")))) assert len(actual) == len(expected) assert actual == expected