Skip to content

Commit 30276b3

Browse files
committed
TEST: Update in_testing fixture
1 parent 108f03c commit 30276b3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

nipype/conftest.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
import numpy
33
import os
44

5+
DATADIR = os.path.realpath(
6+
os.path.join(os.path.dirname(__file__), 'testing/data'))
7+
58

69
@pytest.fixture(autouse=True)
710
def add_np(doctest_namespace):
811
doctest_namespace['np'] = numpy
912
doctest_namespace['os'] = os
1013

11-
filepath = os.path.dirname(os.path.realpath(__file__))
12-
datadir = os.path.realpath(os.path.join(filepath, 'testing/data'))
13-
doctest_namespace["datadir"] = datadir
14+
doctest_namespace["datadir"] = DATADIR
1415

1516

16-
@pytest.fixture(scope='session', autouse=True)
17-
def in_testing():
18-
datadir = os.path.realpath(
19-
os.path.join(os.path.dirname(__file__), 'testing/data'))
20-
origdir = os.getcwd()
21-
os.chdir(datadir)
22-
yield
23-
os.chdir(origdir)
17+
@pytest.fixture(autouse=True)
18+
def in_testing(request):
19+
# This seems to be a reliable way to distinguish tests from doctests
20+
if request.function is None:
21+
os.chdir(DATADIR)

0 commit comments

Comments
 (0)