@@ -1358,7 +1358,7 @@ def test_bids_path_label_vs_index_entity():
13581358
13591359
13601360@testing .requires_testing_data
1361- def test_meg_calibration_fpath (return_bids_test_dir ):
1361+ def test_meg_calibration_fpath (return_bids_test_dir , tmp_path ):
13621362 """Test BIDSPath.meg_calibration_fpath."""
13631363 bids_root = return_bids_test_dir
13641364
@@ -1382,15 +1382,18 @@ def test_meg_calibration_fpath(return_bids_test_dir):
13821382 with pytest .raises (ValueError , match = "Can only find .* for MEG" ):
13831383 bids_path_ .meg_calibration_fpath
13841384
1385- # Delete the fine-calibration file. BIDSPath.meg_calibration_fpath
1386- # should then return None.
1385+ # Move the fine-calibration file. BIDSPath.meg_calibration_fpath should then be None
13871386 bids_path_ = _bids_path .copy ().update (subject = "01" , root = bids_root )
1388- Path (bids_path_ .meg_calibration_fpath ).unlink ()
1387+ src = Path (bids_path_ .meg_calibration_fpath )
1388+ src .rename (tmp_path / src .name )
13891389 assert bids_path_ .meg_calibration_fpath is None
1390+ # restore the file
1391+ (tmp_path / src .name ).rename (src )
1392+ assert bids_path_ .meg_calibration_fpath is not None
13901393
13911394
13921395@testing .requires_testing_data
1393- def test_meg_crosstalk_fpath (return_bids_test_dir ):
1396+ def test_meg_crosstalk_fpath (return_bids_test_dir , tmp_path ):
13941397 """Test BIDSPath.meg_crosstalk_fpath."""
13951398 bids_root = return_bids_test_dir
13961399
@@ -1414,11 +1417,14 @@ def test_meg_crosstalk_fpath(return_bids_test_dir):
14141417 with pytest .raises (ValueError , match = "Can only find .* for MEG" ):
14151418 bids_path .meg_crosstalk_fpath
14161419
1417- # Delete the crosstalk file. BIDSPath.meg_crosstalk_fpath should then
1418- # return None.
1420+ # Move the crosstalk file. BIDSPath.meg_crosstalk_fpath should then be None.
14191421 bids_path = _bids_path .copy ().update (subject = "01" , root = bids_root )
1420- Path (bids_path .meg_crosstalk_fpath ).unlink ()
1422+ src = Path (bids_path .meg_crosstalk_fpath )
1423+ src .rename (tmp_path / src .name )
14211424 assert bids_path .meg_crosstalk_fpath is None
1425+ # restore the file
1426+ (tmp_path / src .name ).rename (src )
1427+ assert bids_path .meg_crosstalk_fpath is not None
14221428
14231429
14241430@testing .requires_testing_data
0 commit comments