Skip to content

Commit

Permalink
Add failing test based on omry#831
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 committed Dec 2, 2021
1 parent 197129e commit 25a989d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/structured_conf/test_structured_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ def validate(cfg: DictConfig) -> None:
conf1 = OmegaConf.structured(module.ConfigWithList())
validate(conf1)

def test_config_with_list_nondefault_values(self, module: Any) -> None:
conf1 = OmegaConf.structured(module.ConfigWithList(list1=[4, 5, 6]))
assert conf1.list1 == [4, 5, 6]

conf2 = OmegaConf.structured(module.ConfigWithList(list1=MISSING))
assert OmegaConf.is_missing(conf2, "list1")

def test_assignment_to_nested_structured_config(self, module: Any) -> None:
conf = OmegaConf.structured(module.NestedConfig)
with raises(ValidationError):
Expand All @@ -229,6 +236,13 @@ def validate(cfg: DictConfig) -> None:
conf1 = OmegaConf.structured(module.ConfigWithDict())
validate(conf1)

def test_config_with_dict_nondefault_values(self, module: Any) -> None:
conf1 = OmegaConf.structured(module.ConfigWithDict(dict1={"baz": "qux"}))
assert conf1.dict1 == {"baz": "qux"}

conf2 = OmegaConf.structured(module.ConfigWithDict(dict1=MISSING))
assert OmegaConf.is_missing(conf2, "dict1")

def test_structured_config_struct_behavior(self, module: Any) -> None:
def validate(cfg: DictConfig) -> None:
assert not OmegaConf.is_struct(cfg)
Expand Down

0 comments on commit 25a989d

Please sign in to comment.