MCPcopy
hub / github.com/treeverse/dvc / test_foreach_interpolated_simple_list

Function test_foreach_interpolated_simple_list

tests/func/parsing/test_foreach.py:82–95  ·  view source on GitHub ↗
(tmp_dir, dvc)

Source from the content-addressed store, hash-verified

80
81
82def test_foreach_interpolated_simple_list(tmp_dir, dvc):
83 foreach_data = ["foo", "bar", "baz"]
84 vars_ = {"models": foreach_data}
85 resolver = DataResolver(dvc, tmp_dir.fs_path, {"vars": [vars_]})
86 data = {"foreach": "${models}", "do": {"cmd": "echo ${item}"}}
87 definition = ForeachDefinition(resolver, resolver.context, "build", data)
88
89 assert definition.resolve_all() == {
90 "build@foo": {"cmd": "echo foo"},
91 "build@bar": {"cmd": "echo bar"},
92 "build@baz": {"cmd": "echo baz"},
93 }
94 assert resolver.context == {"models": foreach_data}
95 assert not any(item for item in resolver.tracked_vars.values())
96
97
98@pytest.mark.parametrize("foreach_def", ["${item.thresh}", "${item[thresh]}"])

Callers

nothing calls this directly

Calls 3

resolve_allMethod · 0.95
DataResolverClass · 0.90
ForeachDefinitionClass · 0.90

Tested by

no test coverage detected