Skip to content

Commit

Permalink
Better explanation of `test_invalid_intermediate_result_when_not_thro…
Browse files Browse the repository at this point in the history
…wing()`
  • Loading branch information
odelalleau committed Feb 12, 2021
1 parent 9247d0b commit dfea0a0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,19 @@ def test_invalid_intermediate_result_when_not_throwing(
ref: str, restore_resolvers: Any
) -> None:
"""
Check that the resolution of nested interpolations stops on missing / resolution failure.
Test the handling of missing / resolution failures in nested interpolations.
The main goal of this test is to make sure that the resolution of an interpolation
is stopped immediately when a missing / resolution failure occurs, even if
`throw_on_missing` and `throw_on_resolution_failure` are set to False.
When this happens while dereferencing a node, the result should be `None`.
"""
OmegaConf.register_new_resolver("check_none", lambda x: x is None)
cfg = OmegaConf.create({"x": f"${{check_none:${{{ref}}}}}", "missing": "???"})

def fail_if_called(x: Any) -> None:
assert False

OmegaConf.register_new_resolver("fail_if_called", fail_if_called)
cfg = OmegaConf.create({"x": f"${{fail_if_called:${{{ref}}}}}", "missing": "???"})
x_node = cfg._get_node("x")
assert isinstance(x_node, Node)
assert (
Expand Down

0 comments on commit dfea0a0

Please sign in to comment.