Skip to content

Commit baec874

Browse files
josephmjeoesteban
authored andcommitted
add pytest fixtures
1 parent 4707fb2 commit baec874

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

dmriprep/conftest.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66
import nibabel as nb
77
import pytest
8+
from bids.layout import BIDSLayout
89
from dipy.data.fetcher import _make_fetcher, UW_RW_URL
910

1011
_dipy_datadir_root = os.getenv('DMRIPREP_TESTS_DATA') or Path.home()
@@ -28,6 +29,20 @@
2829
'bvals': np.loadtxt(dipy_datadir / "HARDI193.bval"),
2930
}
3031

32+
test_data_env = os.getenv('TEST_DATA_HOME', '/tmp/data')
33+
test_output_dir = os.getenv('TEST_OUTPUT_DIR')
34+
test_workdir = os.getenv('TEST_WORK_DIR')
35+
36+
layouts = {p.name: BIDSLayout(str(p), validate=False, derivatives=True)
37+
for p in Path(test_data_env).glob('*') if p.is_dir()}
38+
39+
40+
def pytest_report_header(config):
41+
msg = "Datasets found: %s" % ', '.join([v.root for v in layouts.values()])
42+
if test_output_dir is not None:
43+
msg += '\nOutput folder: %s' % Path(test_output_dir).resolve()
44+
return msg
45+
3146

3247
@pytest.fixture(autouse=True)
3348
def doctest_autoimport(doctest_namespace):
@@ -48,3 +63,18 @@ def doctest_autoimport(doctest_namespace):
4863
def dipy_test_data(scope='session'):
4964
"""Create a temporal directory shared across tests to pull data in."""
5065
return _sherbrooke_data
66+
67+
68+
@pytest.fixture
69+
def workdir():
70+
return None if test_workdir is None else Path(test_workdir)
71+
72+
73+
@pytest.fixture
74+
def output_path():
75+
return None if test_output_dir is None else Path(test_output_dir)
76+
77+
78+
@pytest.fixture
79+
def bids_layouts():
80+
return layouts

0 commit comments

Comments
 (0)