Skip to content

Commit

Permalink
factor out fname check when no splitting occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalt committed Aug 14, 2023
1 parent 1747aac commit da265fb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions mne/tests/test_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit da265fb

Please sign in to comment.