@@ -321,13 +321,15 @@ def _build_nifti_cohort(tmp_path):
321321 return group_mask_file , cohort_csv
322322
323323
324- def test_nifti_tiledb_fails_when_output_already_exists (tmp_path , monkeypatch ):
324+ def test_nifti_tiledb_fails_when_output_already_exists (tmp_path , monkeypatch , caplog ):
325325 """Regression test for https://github.com/PennLINC/ModelArrayIO/issues/39.
326326
327- The TileDB backend should raise an error when the output directory already
328- contains arrays from a previous run (tiledb.Array.create fails if the URI
329- already exists) .
327+ The TileDB backend should succeed when the output directory already contains
328+ arrays from a previous run, removing and recreating them, and should emit a
329+ warning for each removed array .
330330 """
331+ import logging
332+
331333 group_mask_file , cohort_csv = _build_nifti_cohort (tmp_path )
332334 out_tdb = tmp_path / 'out.tdb'
333335 monkeypatch .chdir (tmp_path )
@@ -346,11 +348,16 @@ def test_nifti_tiledb_fails_when_output_already_exists(tmp_path, monkeypatch):
346348 'gzip' ,
347349 ]
348350
349- # First run should succeed
350- assert modelarrayio_main (cli_args ) == 0
351+ # First run should succeed without any "Removing existing array" warnings.
352+ with caplog .at_level (logging .WARNING , logger = 'modelarrayio.storage.tiledb_storage' ):
353+ assert modelarrayio_main (cli_args ) == 0
351354 assert out_tdb .exists ()
352355 assert tiledb .object_type (str (out_tdb / 'scalars' / 'FA' / 'values' )) is not None
353-
354- # Second run to the same output directory should succeed now that existing
355- # arrays are removed before re-creation (regression for issue #39).
356- assert modelarrayio_main (cli_args ) == 0
356+ assert not any ('Removing existing array' in r .message for r in caplog .records )
357+
358+ # Second run to the same output directory should succeed (regression for
359+ # issue #39) and emit a warning for the pre-existing array that was removed.
360+ caplog .clear ()
361+ with caplog .at_level (logging .WARNING , logger = 'modelarrayio.storage.tiledb_storage' ):
362+ assert modelarrayio_main (cli_args ) == 0
363+ assert any ('Removing existing array' in r .message for r in caplog .records )
0 commit comments