Skip to content

Commit 979e10f

Browse files
committed
add unit test
1 parent c86082f commit 979e10f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/unit/sagemaker/modules/train/test_model_trainer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,18 @@ def test_hyperparameters_invalid(mock_exists, modules_session):
11611161
hyperparameters="hyperparameters.yaml",
11621162
)
11631163

1164+
# YAML contents must be a valid mapping
1165+
mock_file_open = mock_open(read_data="invalid")
1166+
with patch("builtins.open", mock_file_open):
1167+
with pytest.raises(ValueError, match="Must be a valid JSON or YAML file."):
1168+
ModelTrainer(
1169+
training_image=DEFAULT_IMAGE,
1170+
role=DEFAULT_ROLE,
1171+
sagemaker_session=modules_session,
1172+
compute=DEFAULT_COMPUTE_CONFIG,
1173+
hyperparameters="hyperparameters.yaml",
1174+
)
1175+
11641176
# Must be valid YAML
11651177
mock_file_open = mock_open(read_data="* invalid")
11661178
with patch("builtins.open", mock_file_open):

0 commit comments

Comments
 (0)