Skip to content

Commit 103f4e9

Browse files
author
Maximilien Chaumon
committed
removed monkeypatched glob test that was crashing on windows and not useful anyway.
1 parent 51f254a commit 103f4e9

File tree

1 file changed

+0
-59
lines changed

1 file changed

+0
-59
lines changed

mne_bids/tests/test_path.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,65 +1277,6 @@ def test_return_root_paths_entity_aware(tmp_path):
12771277
assert all("sub-subjA" in str(p) for p in subj_paths)
12781278

12791279

1280-
def test_return_root_paths_monkeypatched_glob(monkeypatch):
1281-
"""Unit test for `_return_root_paths` that monkeypatches glob.iglob.
1282-
1283-
This avoids relying on filesystem behavior and asserts that the
1284-
function converts strings returned by glob.iglob into Path objects and
1285-
applies the `ignore_json` filter correctly.
1286-
"""
1287-
from mne_bids.path import _return_root_paths
1288-
1289-
fake_root = "/fake/root"
1290-
1291-
# Simulate iglob returning a mix of json and data files (relative paths)
1292-
fake_results = [
1293-
"sub-subjA/ses-sesA/meg/sub-subjA_ses-sesA_meg.fif",
1294-
"sub-subjA/ses-sesA/meg/sub-subjA_ses-sesA_meg.json",
1295-
"sub-subjB/ses-sesA/eeg/sub-subjB_ses-sesA_eeg.edf",
1296-
]
1297-
1298-
def fake_iglob(pattern, root_dir=None, recursive=False):
1299-
# ensure pattern was constructed as relative to root
1300-
assert str(root_dir) == fake_root
1301-
return iter(fake_results)
1302-
1303-
# monkeypatch glob.iglob to return our fake results
1304-
monkeypatch.setattr("glob.iglob", fake_iglob)
1305-
1306-
# monkeypatch _filter_paths_optimized to avoid filesystem checks
1307-
from mne_bids import path as mb_path
1308-
1309-
def fake_filter(paths, ignore_json):
1310-
# convert returned strings into Path objects rooted at fake_root
1311-
return [
1312-
Path(fake_root, p)
1313-
for p in fake_results
1314-
if (not ignore_json) or (not p.endswith(".json"))
1315-
]
1316-
1317-
monkeypatch.setattr(mb_path, "_filter_paths_optimized", fake_filter)
1318-
1319-
# ignore_json=True should filter out the .json entry
1320-
paths = _return_root_paths(
1321-
fake_root,
1322-
datatype=("meg", "eeg"),
1323-
ignore_json=True,
1324-
entities={"subject": "subjA"},
1325-
)
1326-
assert all(isinstance(p, Path) for p in paths)
1327-
# only the .fif entry for subjA should remain
1328-
assert any(p.suffix == ".fif" and "sub-subjA" in str(p) for p in paths)
1329-
1330-
# ignore_json=False should include the .json entry
1331-
paths_all = _return_root_paths(
1332-
fake_root,
1333-
datatype=("meg", "eeg"),
1334-
ignore_json=False,
1335-
entities={"subject": "subjA"},
1336-
)
1337-
assert any(str(p).endswith(".json") for p in paths_all)
1338-
13391280

13401281
@pytest.mark.filterwarnings(warning_str["meas_date_set_to_none"])
13411282
@pytest.mark.filterwarnings(warning_str["channel_unit_changed"])

0 commit comments

Comments
 (0)