Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
milocress committed Jun 5, 2024
1 parent 0fc5148 commit f9f8ab2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 3 additions & 6 deletions tests/a_scripts/eval/test_eval_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def test_mispelled_mandatory_params_fail(self, cfg: DictConfig) -> None:
omegaconf.errors.InterpolationKeyError,
omegaconf.errors.MissingMandatoryValue,
TypeError,
ValueError,
)):
cfg[p + '-mispelled'] = cfg.pop(p)
main(cfg)
cfg[p] = cfg.pop(p + '-mispelled')

def test_optional_mispelled_params_raise_warning(
def test_optional_mispelled_params_raise_error(
self,
cfg: DictConfig,
) -> None:
Expand All @@ -67,15 +68,11 @@ def test_optional_mispelled_params_raise_warning(
orig_value = cfg.pop(param, None)
updated_param = param + '-mispelling'
cfg[updated_param] = orig_value
with warnings.catch_warnings(record=True) as warning_list:
with pytest.raises(ValueError):
try:
main(cfg)
except:
pass
assert any(
f'Unused parameter {updated_param} found in cfg.' in
str(warning.message) for warning in warning_list
)
# restore configs.
cfg = copy.deepcopy(old_cfg)

Expand Down
8 changes: 2 additions & 6 deletions tests/a_scripts/train/test_train_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_missing_mandatory_parameters_fail(self, cfg: DictConfig) -> None:
main(cfg)
cfg[param] = orig_param

def test_optional_misspelled_params_raise_warning(
def test_optional_misspelled_params_raise_error(
self,
cfg: DictConfig,
) -> None:
Expand All @@ -113,15 +113,11 @@ def test_optional_misspelled_params_raise_warning(
orig_value = cfg.pop(param, None)
updated_param = param + '-misspelling'
cfg[updated_param] = orig_value
with warnings.catch_warnings(record=True) as warning_list:
with pytest.raises(ValueError):
try:
main(cfg)
except:
pass
assert any(
f'Unused parameter {updated_param} found in cfg.' in
str(warning.message) for warning in warning_list
)
# restore configs.
cfg = copy.deepcopy(old_cfg)

Expand Down

0 comments on commit f9f8ab2

Please sign in to comment.