From da265fb285e9755a07bde28baec3c6b34278e089 Mon Sep 17 00:00:00 2001 From: Dmitrii Altukhov Date: Mon, 14 Aug 2023 20:16:22 +0200 Subject: [PATCH] factor out fname check when no splitting occurs --- mne/tests/test_epochs.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mne/tests/test_epochs.py b/mne/tests/test_epochs.py index eed3d99bcd4..7f9e5784906 100644 --- a/mne/tests/test_epochs.py +++ b/mne/tests/test_epochs.py @@ -1556,16 +1556,9 @@ def test_split_saving(tmp_path, epochs_to_split, preload): def test_split_naming(tmp_path, epochs_to_split): """Test naming of the split files.""" epochs, _, n_files = epochs_to_split - # Check that if BIDS is used and no split is needed it defaults to - # simple writing without _split- entity. split_fname = tmp_path / "test_epo.fif" split_fname_neuromag_part1 = tmp_path / f"test_epo-{n_files + 1}.fif" split_fname_bids_part1 = tmp_path / f"test_split-{n_files + 1:02d}_epo.fif" - - epochs.save(split_fname, split_naming="bids", verbose=True) - assert split_fname.is_file() - assert not split_fname_bids_part1.is_file() - os.remove(split_fname) # we don't test for reserved files as it's not implemented here epochs.save(split_fname, split_size="1.4MB", verbose=True) @@ -1583,6 +1576,20 @@ def test_split_naming(tmp_path, epochs_to_split): assert split_fname_bids_part1.is_file() +def test_saved_fname_no_splitting(tmp_path, epochs_to_split): + """Test saved fname doesn't get split suffix when splitting not needed.""" + # Check that if BIDS is used and no split is needed it defaults to + # simple writing without _split- entity. + epochs, _, n_files = epochs_to_split + split_fname = tmp_path / "test_epo.fif" + split_fname_bids_part1 = tmp_path / f"test_split-{n_files + 1:02d}_epo.fif" + + epochs.save(split_fname, split_naming="bids", verbose=True) + + assert split_fname.is_file() + assert not split_fname_bids_part1.is_file() + + @pytest.mark.parametrize("split_naming", ["neuromag", "bids"]) def test_saving_fails_with_not_permitted_overwrite( tmp_path, epochs_factory, split_naming