File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,12 @@ def __len__(self) -> int:
3737 def from_file (cls , manifest_path : Path ) -> Self :
3838 """Load the export manifest from the JSON file."""
3939 with manifest_path .open ("r" , encoding = "utf-8" ) as file :
40- return cls .model_validate (json .load (file ))
40+ content = file .read ()
41+
42+ if not content .strip ():
43+ return cls ()
44+
45+ return cls .model_validate (json .loads (content ))
4146
4247 def add_entry (self , absolute_path : Path ) -> None :
4348 """Append a new file to the manifest."""
Original file line number Diff line number Diff line change @@ -49,6 +49,16 @@ def test_export_manifest_from_file_not_exist(tmp_path: Path) -> None:
4949 ExportManifest .from_file (tmp_path / MANIFEST_FILENAME )
5050
5151
52+ def test_export_manifest_from_empty_file (tmp_path : Path ) -> None :
53+ """Test that an empty manifest file is loaded as a new manifest."""
54+ manifest_path = tmp_path / MANIFEST_FILENAME
55+ manifest_path .touch ()
56+
57+ manifest = ExportManifest .from_file (manifest_path )
58+
59+ assert len (manifest ) == 0
60+
61+
5262def test_get_manifest_path_realization_context (runpath_no_dotfmu : Path ) -> None :
5363 """Test that the manifest path is correctly derived in a realization context."""
5464 # check test assumption that the fixture points to the runpath
You can’t perform that action at this time.
0 commit comments