Skip to content

Commit a58fec3

Browse files
committed
Raise ValueError on save without filename
1 parent 0a63751 commit a58fec3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cadet/h5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def save(self, lock: bool = False) -> None:
136136
with h5py.File(self.filename, 'w') as h5file:
137137
recursively_save(h5file, '/', self.root, self.transform)
138138
else:
139-
print("Filename must be set before save can be used")
139+
raise ValueError("Filename must be set before save can be used")
140140

141141
def save_json(self, filename: str | Path) -> None:
142142
"""

tests/test_h5.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ def test_load_nonexistent_file():
164164
instance.load()
165165

166166

167-
# def test_save_without_filename(h5_instance):
168-
# with pytest.raises(ValueError):
169-
# h5_instance.save()
167+
def test_save_without_filename(h5_instance):
168+
with pytest.raises(ValueError):
169+
h5_instance.save()
170170

171171

172172
def test_load_json_with_invalid_data(temp_json_file):

0 commit comments

Comments
 (0)