Skip to content

Commit 52f379c

Browse files
committed
changing str(tmpdir) to tmpdir.strpath in tests
1 parent 20b113c commit 52f379c

29 files changed

+77
-77
lines changed

nipype/algorithms/tests/test_compcor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TestCompCor():
2121
@pytest.fixture(autouse=True)
2222
def setup_class(self, tmpdir):
2323
# setup
24-
self.temp_dir = str(tmpdir)
24+
self.temp_dir = tmpdir.strpath
2525
os.chdir(self.temp_dir)
2626
noise = np.fromfunction(self.fake_noise_fun, self.fake_data.shape)
2727
self.realigned_file = utils.save_toy_nii(self.fake_data + noise,

nipype/algorithms/tests/test_confounds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
def test_fd(tmpdir):
23-
tempdir = str(tmpdir)
23+
tempdir = tmpdir.strpath
2424
ground_truth = np.loadtxt(example_data('fsl_motion_outliers_fd.txt'))
2525
fdisplacement = FramewiseDisplacement(in_file=example_data('fsl_mcflirt_movpar.txt'),
2626
out_file=tempdir + '/fd.txt',
@@ -43,7 +43,7 @@ def test_dvars(tmpdir):
4343
in_mask=example_data('ds003_sub-01_mc_brainmask.nii.gz'),
4444
save_all=True,
4545
intensity_normalization=0)
46-
os.chdir(str(tmpdir))
46+
os.chdir(tmpdir.strpath)
4747
res = dvars.run()
4848

4949
dv1 = np.loadtxt(res.outputs.out_all, skiprows=1)

nipype/algorithms/tests/test_errormap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def test_errormap(tmpdir):
1313

14-
tempdir = str(tmpdir)
14+
tempdir = tmpdir.strpath
1515
# Single-Spectual
1616
# Make two fake 2*2*2 voxel volumes
1717
volume1 = np.array([[[2.0, 8.0], [1.0, 2.0]], [[1.0, 9.0], [0.0, 3.0]]]) # John von Neumann's birthday

nipype/algorithms/tests/test_mesh_ops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed")
1717
def test_ident_distances(tmpdir):
18-
tempdir = str(tmpdir)
18+
tempdir = tmpdir.strpath
1919
os.chdir(tempdir)
2020

2121
in_surf = example_data('surf01.vtk')
@@ -33,7 +33,7 @@ def test_ident_distances(tmpdir):
3333

3434
@pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed")
3535
def test_trans_distances(tmpdir):
36-
tempdir = str(tmpdir)
36+
tempdir = tmpdir.strpath
3737
from ...interfaces.vtkbase import tvtk
3838

3939
in_surf = example_data('surf01.vtk')
@@ -63,14 +63,14 @@ def test_trans_distances(tmpdir):
6363

6464
@pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed")
6565
def test_warppoints(tmpdir):
66-
os.chdir(str(tmpdir))
66+
os.chdir(tmpdir.strpath)
6767

6868
# TODO: include regression tests for when tvtk is installed
6969

7070

7171
@pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed")
7272
def test_meshwarpmaths(tmpdir):
73-
os.chdir(str(tmpdir))
73+
os.chdir(tmpdir.strpath)
7474

7575
# TODO: include regression tests for when tvtk is installed
7676

nipype/algorithms/tests/test_modelgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def test_modelgen1(tmpdir):
20-
tempdir = str(tmpdir)
20+
tempdir = tmpdir.strpath
2121
filename1 = os.path.join(tempdir, 'test1.nii')
2222
filename2 = os.path.join(tempdir, 'test2.nii')
2323
Nifti1Image(np.random.rand(10, 10, 10, 200), np.eye(4)).to_filename(filename1)
@@ -56,7 +56,7 @@ def test_modelgen1(tmpdir):
5656

5757

5858
def test_modelgen_spm_concat(tmpdir):
59-
tempdir = str(tmpdir)
59+
tempdir = tmpdir.strpath
6060
filename1 = os.path.join(tempdir, 'test1.nii')
6161
filename2 = os.path.join(tempdir, 'test2.nii')
6262
Nifti1Image(np.random.rand(10, 10, 10, 30), np.eye(4)).to_filename(filename1)
@@ -122,7 +122,7 @@ def test_modelgen_spm_concat(tmpdir):
122122

123123

124124
def test_modelgen_sparse(tmpdir):
125-
tempdir = str(tmpdir)
125+
tempdir = tmpdir.strpath
126126
filename1 = os.path.join(tempdir, 'test1.nii')
127127
filename2 = os.path.join(tempdir, 'test2.nii')
128128
Nifti1Image(np.random.rand(10, 10, 10, 50), np.eye(4)).to_filename(filename1)

nipype/algorithms/tests/test_normalize_tpms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
def test_normalize_tpms(tmpdir):
21-
tempdir = str(tmpdir)
21+
tempdir = tmpdir.strpath
2222

2323
in_mask = example_data('tpms_msk.nii.gz')
2424
mskdata = nb.load(in_mask, mmap=NUMPY_MMAP).get_data()

nipype/algorithms/tests/test_overlap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def check_close(val1, val2):
2020
in1 = example_data('segmentation0.nii.gz')
2121
in2 = example_data('segmentation1.nii.gz')
2222

23-
os.chdir(str(tmpdir))
23+
os.chdir(tmpdir.strpath)
2424
overlap = Overlap()
2525
overlap.inputs.volume1 = in1
2626
overlap.inputs.volume2 = in1

nipype/algorithms/tests/test_splitmerge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def test_split_and_merge(tmpdir):
1414
from nipype.algorithms.misc import split_rois, merge_rois
1515

1616
in_mask = example_data('tpms_msk.nii.gz')
17-
dwfile = op.join(str(tmpdir), 'dwi.nii.gz')
17+
dwfile = op.join(tmpdir.strpath, 'dwi.nii.gz')
1818
mskdata = nb.load(in_mask, mmap=NUMPY_MMAP).get_data()
1919
aff = nb.load(in_mask, mmap=NUMPY_MMAP).affine
2020

2121
dwshape = (mskdata.shape[0], mskdata.shape[1], mskdata.shape[2], 6)
2222
dwdata = np.random.normal(size=dwshape)
23-
os.chdir(str(tmpdir))
23+
os.chdir(tmpdir.strpath)
2424
nb.Nifti1Image(dwdata.astype(np.float32),
2525
aff, None).to_filename(dwfile)
2626

nipype/algorithms/tests/test_tsnr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestTSNR():
3030
@pytest.fixture(autouse=True)
3131
def setup_class(self, tmpdir):
3232
# setup temp folder
33-
self.temp_dir = str(tmpdir)
33+
self.temp_dir = tmpdir.strpath
3434
os.chdir(self.temp_dir)
3535

3636
utils.save_toy_nii(self.fake_data, self.in_filenames['in_file'])

nipype/caching/tests/test_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_caching(tmpdir):
2525
try:
2626
# Prevent rerun to check that evaluation is computed only once
2727
config.set('execution', 'stop_on_first_rerun', 'true')
28-
mem = Memory(str(tmpdir))
28+
mem = Memory(tmpdir.strpath)
2929
first_nb_run = nb_runs
3030
results = mem.cache(SideEffectInterface)(input1=2, input2=1)
3131
assert nb_runs == first_nb_run + 1

nipype/interfaces/cmtk/tests/test_nbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def creating_graphs(tmpdir):
1818
for idx, name in enumerate(graphnames):
1919
graph = np.random.rand(10,10)
2020
G = nx.from_numpy_matrix(graph)
21-
out_file = str(tmpdir) + graphnames[idx] + '.pck'
21+
out_file = tmpdir.strpath + graphnames[idx] + '.pck'
2222
# Save as pck file
2323
nx.write_gpickle(G, out_file)
2424
graphlist.append(out_file)

nipype/interfaces/freesurfer/tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@pytest.mark.skipif(no_freesurfer(), reason="freesurfer is not installed")
1717
def test_concatenate(tmpdir):
18-
tempdir = str(tmpdir)
18+
tempdir = tmpdir.strpath
1919
os.chdir(tempdir)
2020
in1 = os.path.join(tempdir, 'cont1.nii')
2121
in2 = os.path.join(tempdir, 'cont2.nii')

nipype/interfaces/fsl/tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@pytest.mark.skipif(no_fsl(), reason="fsl is not installed")
1515
def test_MultipleRegressDesign(tmpdir):
16-
os.chdir(str(tmpdir))
16+
os.chdir(tmpdir.strpath)
1717
foo = fsl.MultipleRegressDesign()
1818
foo.inputs.regressors = dict(voice_stenght=[1, 1, 1], age=[0.2, 0.4, 0.5], BMI=[1, -1, 2])
1919
con1 = ['voice_and_age', 'T', ['age', 'voice_stenght'], [0.5, 0.5]]

nipype/interfaces/fsl/tests/test_preprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def fsl_name(obj, fname):
2727
@pytest.fixture()
2828
def setup_infile(tmpdir):
2929
ext = Info.output_type_to_ext(Info.output_type())
30-
tmp_dir = str(tmpdir)
30+
tmp_dir = tmpdir.strpath
3131
tmp_infile = os.path.join(tmp_dir, 'foo' + ext)
3232
open(tmp_infile, 'w')
3333

@@ -183,7 +183,7 @@ def _run_and_test(opts, output_base):
183183
@pytest.fixture()
184184
def setup_flirt(tmpdir):
185185
ext = Info.output_type_to_ext(Info.output_type())
186-
tmp_dir = str(tmpdir)
186+
tmp_dir = tmpdir.strpath
187187
_, infile = tempfile.mkstemp(suffix=ext, dir=tmp_dir)
188188
_, reffile = tempfile.mkstemp(suffix=ext, dir=tmp_dir)
189189

@@ -549,7 +549,7 @@ def setup_fugue(tmpdir):
549549
import os.path as op
550550

551551
d = np.ones((80, 80, 80))
552-
tmp_dir = str(tmpdir)
552+
tmp_dir = tmpdir.strpath
553553
infile = op.join(tmp_dir, 'dumbfile.nii.gz')
554554
nb.Nifti1Image(d, None, None).to_filename(infile)
555555

nipype/interfaces/tests/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_bunch_hash():
7070

7171
@pytest.fixture(scope="module")
7272
def setup_file(request, tmpdir_factory):
73-
tmp_dir = str(tmpdir_factory.mktemp('files'))
73+
tmp_dir = tmpdir_factory.mktemp('files').strpath
7474
tmp_infile = os.path.join(tmp_dir, 'foo.txt')
7575
with open(tmp_infile, 'w') as fp:
7676
fp.writelines([u'123456789'])
@@ -412,7 +412,7 @@ def _run_interface(self, runtime):
412412

413413

414414
def test_BaseInterface_load_save_inputs(tmpdir):
415-
tmp_json = os.path.join(str(tmpdir), 'settings.json')
415+
tmp_json = os.path.join(tmpdir.strpath, 'settings.json')
416416

417417
class InputSpec(nib.TraitedSpec):
418418
input1 = nib.traits.Int()

nipype/interfaces/tests/test_io.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_s3datagrabber_communication(tmpdir):
117117
dg.inputs.anon = True
118118
dg.inputs.bucket = 'openfmri'
119119
dg.inputs.bucket_path = 'ds001/'
120-
dg.inputs.local_directory = str(tmpdir)
120+
dg.inputs.local_directory = tmpdir.strpath
121121
dg.inputs.sort_filelist = True
122122
dg.inputs.template = '*'
123123
dg.inputs.field_template = dict(func='%s/BOLD/task001_%s/bold.nii.gz',
@@ -147,7 +147,7 @@ def test_datagrabber_order(tmpdir):
147147
tmpdir.join(file_name).open('a').close()
148148

149149
dg = nio.DataGrabber(infields=['sid'])
150-
dg.inputs.base_directory = str(tmpdir)
150+
dg.inputs.base_directory = tmpdir.strpath
151151
dg.inputs.template = '%s_L%d_R*.q*'
152152
dg.inputs.template_args = {'outfiles': [['sid', 1], ['sid', 2],
153153
['sid', 3]]}
@@ -208,7 +208,7 @@ def test_datasink_to_s3(dummy_input, tmpdir):
208208
attr_folder = 'text_file'
209209
output_dir = 's3://' + bucket_name
210210
# Local temporary filepaths for testing
211-
fakes3_dir = str(tmpdir)
211+
fakes3_dir = tmpdir.strpath
212212
input_path = dummy_input
213213

214214
# Start up fake-S3 server
@@ -280,7 +280,7 @@ def test_datasink_localcopy(dummy_input, tmpdir):
280280
'''
281281

282282
# Init variables
283-
local_dir = str(tmpdir)
283+
local_dir = tmpdir.strpath
284284
container = 'outputs'
285285
attr_folder = 'text_file'
286286

@@ -370,7 +370,7 @@ def test_datasink_copydir():
370370

371371

372372
def test_datafinder_depth(tmpdir):
373-
outdir = str(tmpdir)
373+
outdir = tmpdir.strpath
374374
os.makedirs(os.path.join(outdir, '0', '1', '2', '3'))
375375

376376
df = nio.DataFinder()
@@ -387,7 +387,7 @@ def test_datafinder_depth(tmpdir):
387387

388388

389389
def test_datafinder_unpack(tmpdir):
390-
outdir = str(tmpdir)
390+
outdir = tmpdir.strpath
391391
single_res = os.path.join(outdir, "findme.txt")
392392
open(single_res, 'a').close()
393393
open(os.path.join(outdir, "dontfindme"), 'a').close()
@@ -425,7 +425,7 @@ def test_jsonsink_input(tmpdir):
425425
{'new_entry' : 'someValue', 'test' : 'testInfields'}
426426
])
427427
def test_jsonsink(tmpdir, inputs_attributes):
428-
os.chdir(str(tmpdir))
428+
os.chdir(tmpdir.strpath)
429429
js = nio.JSONFileSink(infields=['test'], in_dict={'foo': 'var'})
430430
setattr(js.inputs, 'contrasts.alt', 'someNestedValue')
431431
expected_data = {"contrasts": {"alt": "someNestedValue"}, "foo": "var"}

nipype/interfaces/utility/tests/test_base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212

1313
def test_rename(tmpdir):
14-
os.chdir(str(tmpdir))
14+
os.chdir(tmpdir.strpath)
1515

1616
# Test very simple rename
1717
_ = open("file.txt", "w").close()
1818
rn = utility.Rename(in_file="file.txt", format_string="test_file1.txt")
1919
res = rn.run()
20-
outfile = str(tmpdir.join("test_file1.txt"))
20+
outfile = tmpdir.join("test_file1.txt").strpath
2121
assert res.outputs.out_file == outfile
2222
assert os.path.exists(outfile)
2323

@@ -31,7 +31,7 @@ def test_rename(tmpdir):
3131
rn.inputs.field1 = "test"
3232
rn.inputs.field2 = 2
3333
res = rn.run()
34-
outfile = str(tmpdir.join("test_file2.txt"))
34+
outfile = tmpdir.join("test_file2.txt").strpath
3535
assert res.outputs.out_file == outfile
3636
assert os.path.exists(outfile)
3737

@@ -41,7 +41,7 @@ def test_rename(tmpdir):
4141
({"squeeze" : True}, (0 , [1,2,3]))
4242
])
4343
def test_split(tmpdir, args, expected):
44-
os.chdir(str(tmpdir))
44+
os.chdir(tmpdir.strpath)
4545

4646
node = pe.Node(utility.Split(inlist=list(range(4)),
4747
splits=[1, 3],
@@ -64,7 +64,7 @@ def test_split(tmpdir, args, expected):
6464
[[0, 2, 4], [1, 3, 5]]),
6565
])
6666
def test_merge(tmpdir, args, kwargs, in_lists, expected):
67-
os.chdir(str(tmpdir))
67+
os.chdir(tmpdir.strpath)
6868

6969
node = pe.Node(utility.Merge(*args, **kwargs), name='merge')
7070

nipype/interfaces/utility/tests/test_csv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_csvReader(tmpdir):
1212
"bar,world,5\n",
1313
"baz,goodbye,0.3\n"]
1414
for x in range(2):
15-
name = str(tmpdir.join("testfile.csv"))
15+
name = tmpdir.join("testfile.csv").strpath
1616
with open(name, 'w') as fid:
1717
reader = utility.CSVReader()
1818
if x % 2 == 0:

nipype/interfaces/utility/tests/test_wrappers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def concat_sort(in_arrays):
1616
"""
1717

1818
def test_function(tmpdir):
19-
os.chdir(str(tmpdir))
19+
os.chdir(tmpdir.strpath)
2020

2121
def gen_random_array(size):
2222
import numpy as np
@@ -59,11 +59,11 @@ def should_fail(tmpdir):
5959

6060
def test_should_fail(tmpdir):
6161
with pytest.raises(NameError):
62-
should_fail(str(tmpdir))
62+
should_fail(tmpdir.strpath)
6363

6464

6565
def test_function_with_imports(tmpdir):
66-
os.chdir(str(tmpdir))
66+
os.chdir(tmpdir.strpath)
6767

6868
node = pe.Node(utility.Function(input_names=["size"],
6969
output_names=["random_array"],
@@ -79,7 +79,7 @@ def test_aux_connect_function(tmpdir):
7979
""" This tests excution nodes with multiple inputs and auxiliary
8080
function inside the Workflow connect function.
8181
"""
82-
os.chdir(str(tmpdir))
82+
os.chdir(tmpdir.strpath)
8383

8484
wf = pe.Workflow(name="test_workflow")
8585

nipype/pipeline/engine/tests/test_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def test_parameterize_dirs_false(tmpdir):
661661
n2 = pe.Node(IdentityInterface(fields='in1'), name='Node2')
662662

663663
wf = pe.Workflow(name='Test')
664-
wf.base_dir = str(tmpdir)
664+
wf.base_dir = tmpdir.strpath
665665
wf.config['execution']['parameterize_dirs'] = False
666666
wf.connect([(n1, n2, [('output1', 'in1')])])
667667

0 commit comments

Comments
 (0)