Skip to content

Commit 4711297

Browse files
committed
TST: Add blank files, make available for doctests
1 parent 83deff9 commit 4711297

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

niworkflows/interfaces/conftest.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from pathlib import Path
2+
from shutil import copytree
3+
4+
import pytest
5+
6+
try:
7+
from contextlib import chdir as _chdir
8+
except ImportError: # PY310
9+
import os
10+
from contextlib import contextmanager
11+
12+
@contextmanager # type: ignore
13+
def _chdir(path):
14+
cwd = os.getcwd()
15+
os.chdir(path)
16+
try:
17+
yield
18+
finally:
19+
os.chdir(cwd)
20+
21+
22+
@pytest.fixture(scope="module")
23+
def data_dir():
24+
return Path(__file__).parent / "tests" / "data"
25+
26+
27+
@pytest.fixture(autouse=True)
28+
def _docdir(request, tmp_path):
29+
# Trigger ONLY for the doctests.
30+
doctest_plugin = request.config.pluginmanager.getplugin("doctest")
31+
if isinstance(request.node, doctest_plugin.DoctestItem):
32+
copytree(Path(__file__).parent / "tests" / "data", tmp_path, dirs_exist_ok=True)
33+
34+
# Chdir only for the duration of the test.
35+
with _chdir(tmp_path):
36+
yield
37+
38+
else:
39+
# For normal tests, we have to yield, since this is a yield-fixture.
40+
yield

niworkflows/interfaces/tests/data/bold.nii.gz

Whitespace-only changes.

niworkflows/interfaces/tests/data/lh.bold.func.gii

Whitespace-only changes.

niworkflows/interfaces/tests/data/lh.midthickness.surf.gii

Whitespace-only changes.

niworkflows/interfaces/tests/data/lh.pial.surf.gii

Whitespace-only changes.

niworkflows/interfaces/tests/data/lh.roi.shape.gii

Whitespace-only changes.

niworkflows/interfaces/tests/data/lh.white.surf.gii

Whitespace-only changes.

0 commit comments

Comments
 (0)