Skip to content

Commit

Permalink
tests: indices syntax for parametrization (iterative#4930)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Nov 20, 2020
1 parent 011bd35 commit 6237a66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions tests/unit/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def test_resolve_primitives_list_access():
}
)

assert context.resolve("${dict.0.f}") == "f"
assert context.resolve("${dict.1.fo}") == "fo"
assert context.resolve("${dict.2.foo}") == "foo"
assert context.resolve("${dict.3.foo.0}") == "f"
assert context.resolve("${dict[0].f}") == "f"
assert context.resolve("${dict[1].fo}") == "fo"
assert context.resolve("${dict[2].foo}") == "foo"
assert context.resolve("${dict[3].foo[0]}") == "f"

assert context.resolve("${ dict.1.fo}${dict.3.foo.1}bar") == "foobar"

Expand All @@ -101,3 +101,11 @@ def test_resolve_collection():
resolved = context.resolve(TEMPLATED_DVC_YAML_DATA)
assert resolved == RESOLVED_DVC_YAML_DATA
assert recurse_not_a_node(resolved)


def test_resolve_unicode():
context = Context({"नेपाली": {"चिया": ["चि", "या"]}})
assert context.resolve_str("${नेपाली.चिया[0]}${नेपाली.चिया[1]}") == "चिया"
assert (
context.resolve_str("${नेपाली[चिया][0]}${नेपाली[चिया][1]}") == "चिया"
)
6 changes: 3 additions & 3 deletions tests/unit/test_stage_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cmd": "python script.py ${dict.foo} --out ${dict.bar}",
"outs": ["${dict.bar}"],
"deps": ["${dict.foo}"],
"params": ["${list.0}", "${list.1}"],
"params": ["${list[0]}", "${list[1]}"],
"frozen": "${freeze}",
},
"stage2": {"cmd": "echo ${dict.foo} ${dict.bar}"},
Expand Down Expand Up @@ -118,8 +118,8 @@ def test_set_interpolated_string():
{
"foo": "${dict.foo}",
"bar": "${dict.bar}",
"param1": "${list.0}",
"param2": "${list.1}",
"param1": "${list[0]}",
"param2": "${list[1]}",
"frozen": "${freeze}",
"dict2": "${dict}",
"list2": "${list}",
Expand Down

0 comments on commit 6237a66

Please sign in to comment.