Skip to content

Commit

Permalink
Very minor improvement to unrelated test
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
  • Loading branch information
lebrice committed Jan 5, 2023
1 parent f1fdff2 commit f94a274
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/test_set_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ def test_with_nested_field(tmp_path: Path, add_arguments_before: bool, with_root
save_path = tmp_path / "temp.json"
from simple_parsing.helpers.serialization import encode

saved_config = ConfigWithFoo(foo=Foo(a=456, b="BYE BYE"))

if with_root:
save(encode({"config": ConfigWithFoo(foo=Foo(a=456, b="BYE BYE"))}), path=save_path)
save(encode({"config": saved_config}), path=save_path)
else:
save(ConfigWithFoo(foo=Foo(a=456, b="BYE BYE")), path=save_path)
save(saved_config, path=save_path)
parser.set_defaults(save_path)

if not add_arguments_before:
parser.add_arguments(ConfigWithFoo, dest="config")

args = parser.parse_args("")
assert args.config == ConfigWithFoo(foo=Foo(a=456, b="BYE BYE"))
assert args.config == saved_config

args = parser.parse_args("--a 111".split())
assert args.config == ConfigWithFoo(foo=Foo(a=111, b="BYE BYE"))

0 comments on commit f94a274

Please sign in to comment.