Skip to content

Commit

Permalink
Improve tests and be more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechenberger committed Aug 31, 2022
1 parent 24c81ff commit 06b4356
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,11 +1310,12 @@ def get_bids_path_from_fname(fname, check=True, verbose=None):
suffix, extension = _get_bids_suffix_and_ext(suffix)
else:
suffix = None
extension = Path(fname).suffix
extension = Path(fname).suffix # already starts with a period
if extension == '':
extension = None
else:
extension = f'.{extension}' # prepend period

if extension is not None:
assert extension.startswith('.') # better safe than sorry

datatype = _infer_datatype_from_path(fpath)

Expand Down
6 changes: 6 additions & 0 deletions mne_bids/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,3 +1165,9 @@ def test_setting_entities():

setattr(bids_path, entity_name, None)
assert getattr(bids_path, entity_name) is None


def test_deprecation():
"""Test deprecated behavior."""
with pytest.warns(FutureWarning, match='This will raise an exception'):
BIDSPath(extension='vhdr') # no leading period

0 comments on commit 06b4356

Please sign in to comment.