1+ import sys
2+ import os
3+ import time
4+ import numpy as np
5+ from pathlib import Path
6+
17from nipype .utils .filemanip import save_json , makedirs , to_str
28from nipype .interfaces import fsl
39
410from ..node import Node , Workflow
511from ..auxiliary import FunctionInterface , CurrentInterface
612from ..submitter import Submitter
713
8- import sys , time , os
9- import numpy as np
10- import pytest , pdb
14+ import pytest
15+ import pdb
16+
17+ TEST_DATA_DIR = Path (os .getenv ('PYDRA_TEST_DATA' , '/nonexistent/path' ))
18+ DS114_DIR = TEST_DATA_DIR / 'ds000114'
1119
1220python35_only = pytest .mark .skipif (sys .version_info < (3 , 5 ), reason = "requires Python>3.4" )
1321
@@ -1441,8 +1449,7 @@ def test_workflow_16a(plugin, change_dir):
14411449# testing CurrentInterface that is a temporary wrapper for current interfaces
14421450
14431451
1444- @pytest .mark .skipif (
1445- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1452+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
14461453@pytest .mark .parametrize ("plugin" , Plugins )
14471454@python35_only
14481455def test_current_node_1 (change_dir , plugin ):
@@ -1451,10 +1458,7 @@ def test_current_node_1(change_dir, plugin):
14511458
14521459 nn = Node (
14531460 name = "NA" ,
1454- inputs = {
1455- "in_file" :
1456- "/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1457- },
1461+ inputs = {"in_file" : str (DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" )},
14581462 interface = interf_bet ,
14591463 workingdir = "test_cnd1_{}" .format (plugin ),
14601464 output_names = ["out_file" ])
@@ -1466,17 +1470,16 @@ def test_current_node_1(change_dir, plugin):
14661470 assert "out_file" in nn .output .keys ()
14671471
14681472
1469- @pytest .mark .skipif (
1470- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1473+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
14711474@pytest .mark .parametrize ("plugin" , Plugins )
14721475@python35_only
14731476def test_current_node_2 (change_dir , plugin ):
14741477 """Node with a current interface and mapper"""
14751478 interf_bet = CurrentInterface (interface = fsl .BET (), name = "fsl_interface" )
14761479
14771480 in_file_l = [
1478- "/Users/dorota/nipype_workshop/data/ds000114/ sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" ,
1479- "/Users/dorota/nipype_workshop/data/ds000114/ sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz"
1481+ str ( DS114_DIR / " sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz") ,
1482+ str ( DS114_DIR / " sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz")
14801483 ]
14811484 nn = Node (
14821485 name = "NA" ,
@@ -1496,8 +1499,7 @@ def test_current_node_2(change_dir, plugin):
14961499 assert "NA.in_file:1" in nn .output ["out_file" ].keys ()
14971500
14981501
1499- @pytest .mark .skipif (
1500- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1502+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
15011503@pytest .mark .parametrize ("plugin" , Plugins )
15021504@python35_only
15031505def test_current_wf_1 (change_dir , plugin ):
@@ -1506,10 +1508,7 @@ def test_current_wf_1(change_dir, plugin):
15061508
15071509 nn = Node (
15081510 name = "fsl" ,
1509- inputs = {
1510- "in_file" :
1511- "/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1512- },
1511+ inputs = {"in_file" : str (DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" )},
15131512 interface = interf_bet ,
15141513 workingdir = "nn" ,
15151514 output_names = ["out_file" ],
@@ -1529,8 +1528,7 @@ def test_current_wf_1(change_dir, plugin):
15291528 assert "fsl_out" in wf .output .keys ()
15301529
15311530
1532- @pytest .mark .skipif (
1533- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1531+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
15341532@pytest .mark .parametrize ("plugin" , Plugins )
15351533@python35_only
15361534def test_current_wf_1a (change_dir , plugin ):
@@ -1539,10 +1537,7 @@ def test_current_wf_1a(change_dir, plugin):
15391537
15401538 nn = Node (
15411539 name = "fsl" ,
1542- inputs = {
1543- "in_file" :
1544- "/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1545- },
1540+ inputs = {"in_file" : str (DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" )},
15461541 interface = interf_bet ,
15471542 workingdir = "nn" ,
15481543 output_names = ["out_file" ],
@@ -1562,8 +1557,7 @@ def test_current_wf_1a(change_dir, plugin):
15621557 assert "fsl_out" in wf .output .keys ()
15631558
15641559
1565- @pytest .mark .skipif (
1566- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1560+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
15671561@pytest .mark .parametrize ("plugin" , Plugins )
15681562@python35_only
15691563def test_current_wf_1b (change_dir , plugin ):
@@ -1581,10 +1575,7 @@ def test_current_wf_1b(change_dir, plugin):
15811575 workingdir = "nn" ,
15821576 output_names = ["out_file" ],
15831577 write_state = False ,
1584- inputs = {
1585- "in_file" :
1586- "/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1587- })
1578+ inputs = {"in_file" : str (DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" )})
15881579
15891580 sub = Submitter (plugin = plugin , runnable = wf )
15901581 sub .run ()
@@ -1593,8 +1584,7 @@ def test_current_wf_1b(change_dir, plugin):
15931584 assert "fsl_out" in wf .output .keys ()
15941585
15951586
1596- @pytest .mark .skipif (
1597- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1587+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
15981588@pytest .mark .parametrize ("plugin" , Plugins )
15991589@python35_only
16001590def test_current_wf_1c (change_dir , plugin ):
@@ -1611,10 +1601,7 @@ def test_current_wf_1c(change_dir, plugin):
16111601 workingdir = "nn" ,
16121602 output_names = ["out_file" ],
16131603 write_state = False ,
1614- inputs = {
1615- "in_file" :
1616- "/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1617- })
1604+ inputs = {"in_file" : str (DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" )})
16181605
16191606 sub = Submitter (plugin = plugin , runnable = wf )
16201607 sub .run ()
@@ -1623,17 +1610,16 @@ def test_current_wf_1c(change_dir, plugin):
16231610 assert "fsl_out" in wf .output .keys ()
16241611
16251612
1626- @pytest .mark .skipif (
1627- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1613+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
16281614@pytest .mark .parametrize ("plugin" , Plugins )
16291615@python35_only
16301616def test_current_wf_2 (change_dir , plugin ):
16311617 """Wf with a current interface and mapper"""
16321618 interf_bet = CurrentInterface (interface = fsl .BET (), name = "fsl_interface" )
16331619
16341620 in_file_l = [
1635- "/Users/dorota/nipype_workshop/data/ds000114/ sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" ,
1636- "/Users/dorota/nipype_workshop/data/ds000114/ sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz"
1621+ str ( DS114_DIR / " sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz") ,
1622+ str ( DS114_DIR / " sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz")
16371623 ]
16381624
16391625 nn = Node (
@@ -1662,17 +1648,16 @@ def test_current_wf_2(change_dir, plugin):
16621648 assert 'cw2.in_file:1' in wf .output ["fsl_out" ].keys ()
16631649
16641650
1665- @pytest .mark .skipif (
1666- not os .path .exists ("/Users/dorota/nipype_workshop/data/ds000114" ), reason = "adding data" )
1651+ @pytest .mark .skipif (not DS114_DIR .exists (), reason = "Missing $PYDRA_TEST_DATA/ds000114" )
16671652@pytest .mark .parametrize ("plugin" , Plugins )
16681653@python35_only
16691654def test_current_wf_2a (change_dir , plugin ):
16701655 """Wf with a current interface and mapper"""
16711656 interf_bet = CurrentInterface (interface = fsl .BET (), name = "fsl_interface" )
16721657
16731658 in_file_l = [
1674- "/data/ds000114/ sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz" ,
1675- "/data/ds000114/ sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz"
1659+ str ( DS114_DIR / " sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz") ,
1660+ str ( DS114_DIR / " sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz")
16761661 ]
16771662
16781663 nn = Node (
0 commit comments