@@ -207,33 +207,23 @@ def test_raster_footprint_geometry() -> None:
207207 item .validate ()
208208
209209
210- def test_create_item_from_hdf_without_xml () -> None :
211- """Test that an item can be created from an HDF file when XML is not available.
212-
213- This tests the fallback to extracting metadata directly from the HDF file
214- when the accompanying XML metadata file is not present.
215- """
210+ def test_create_item_from_hdf_without_xml (tmp_path : Path ) -> None :
216211 hdf_file = "MOD10A2.A2022033.h09v05.061.2022042050729.hdf"
217212 source_hdf_path = test_data .get_path (f"data-files/{ hdf_file } " )
218213
219- with TemporaryDirectory () as temporary_directory :
220- # Copy only the HDF file (not the XML) to ensure XML is not available
221- temp_hdf_path = os .path .join (temporary_directory , hdf_file )
222- shutil .copyfile (source_hdf_path , temp_hdf_path )
223-
224- # Verify XML does not exist in temp directory
225- temp_xml_path = f"{ temp_hdf_path } .xml"
226- assert not os .path .exists (temp_xml_path ), "XML file should not exist"
227-
228- # Create item from HDF only - should extract metadata from HDF
229- item = stactools .modis .stac .create_item (temp_hdf_path )
230-
231- # Verify item was created with correct metadata
232- assert item is not None
233- assert item .id .startswith ("MOD10A2.A2022033.h09v05" )
234- assert "hdf" in item .assets
235- assert "metadata" not in item .assets # XML asset should not be present
236- item .validate ()
214+ temp_hdf_path = tmp_path / hdf_file
215+ shutil .copyfile (source_hdf_path , temp_hdf_path )
216+
217+ temp_xml_path = tmp_path / f"{ hdf_file } .xml"
218+ assert not temp_xml_path .exists ()
219+
220+ item = stactools .modis .stac .create_item (str (temp_hdf_path ))
221+
222+ assert item is not None
223+ assert item .id .startswith ("MOD10A2.A2022033.h09v05" )
224+ assert "hdf" in item .assets
225+ assert "metadata" not in item .assets
226+ item .validate ()
237227
238228
239229@pytest .mark .parametrize ("file_name" , PROJECTION_EDGE_FILES )
0 commit comments