parametrization: Support keys of the dictionary to be interpolated (#4869)

This commit is contained in:
Saugat Pachhai
2020-11-10 17:32:58 +05:45
committed by GitHub
parent 2e9fa0607e
commit 4220baa602
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -297,7 +297,7 @@ class Context(CtxDict):
resolve = rpartial(self.resolve, unwrap)
if isinstance(src, Mapping):
return {key: resolve(value) for key, value in src.items()}
return dict(map(resolve, kv) for kv in src.items())
elif isinstance(src, Seq):
return type(src)(map(resolve, src))
elif isinstance(src, str):
+9
View File
@@ -370,3 +370,12 @@ def test_node_value():
assert context["lst"][1].value == 2
assert context["foo"].value == "foo"
def test_resolve_resolves_dict_keys():
d = {"dct": {"foo": "foobar", "persist": True}}
context = Context(d)
assert context.resolve({"${dct.foo}": {"persist": "${dct.persist}"}}) == {
"foobar": {"persist": True}
}