Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Fixed
(`#789 <https://github.com/omni-us/jsonargparse/pull/789>`__).
- Misleading error message for invalid value for ``Literal`` strings (`#790
<https://github.com/omni-us/jsonargparse/pull/790>`__).
- Changing ``omegaconf_absolute_to_relative_paths`` not taking effect after
parsing once (`#805 <https://github.com/omni-us/jsonargparse/pull/805>`__).

Changed
^^^^^^^
Expand Down
11 changes: 7 additions & 4 deletions jsonargparse_tests/test_omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from jsonargparse_tests.conftest import get_parser_help, skip_if_omegaconf_unavailable

if omegaconf_support:
from omegaconf import OmegaConf
from omegaconf import OmegaConf, errors


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -66,9 +66,6 @@ def test_omegaconf_interpolation_in_subcommands(mode, parser, subparser):
subparser.add_argument("--source", type=str)
subparser.add_argument("--target", type=str)

if mode == "omegaconf+absolute":
set_parsing_settings(omegaconf_absolute_to_relative_paths=True)

parser.parser_mode = mode.replace("absolute", "")
subcommands = parser.add_subcommands()
subcommands.add_subcommand("sub", subparser)
Expand All @@ -77,6 +74,12 @@ def test_omegaconf_interpolation_in_subcommands(mode, parser, subparser):
"source": "hello",
"target": "${.source}" if mode == "omegaconf+" else "${source}",
}

if mode == "omegaconf+absolute":
with pytest.raises(errors.InterpolationKeyError):
parser.parse_args(["sub", f"--config={yaml_dump(config)}"])
set_parsing_settings(omegaconf_absolute_to_relative_paths=True)

cfg = parser.parse_args(["sub", f"--config={yaml_dump(config)}"])
assert cfg.sub.target == "hello"

Expand Down