|
16 | 16 | from ....interfaces import base as nib
|
17 | 17 | from ....interfaces import utility as niu
|
18 | 18 | from .... import config
|
19 |
| -from ..utils import clean_working_directory, write_workflow_prov, load_resultfile |
| 19 | +from ..utils import (clean_working_directory, write_workflow_prov, |
| 20 | + save_resultfile, load_resultfile) |
20 | 21 |
|
21 | 22 |
|
22 | 23 | class InputSpec(nib.TraitedSpec):
|
@@ -286,14 +287,31 @@ def test_modify_paths_bug(tmpdir):
|
286 | 287 |
|
287 | 288 |
|
288 | 289 | def test_save_load_resultfile(tmpdir):
|
| 290 | + """Test minimally the save/load functions for result files.""" |
| 291 | + from shutil import copytree |
289 | 292 | tmpdir.chdir()
|
290 | 293 |
|
291 | 294 | spc = pe.Node(StrPathConfuser(in_str='2'), name='spc')
|
292 | 295 | spc.base_dir = tmpdir.mkdir('node').strpath
|
293 | 296 | result = spc.run()
|
294 | 297 |
|
295 |
| - loaded_result = load_resultfile(tmpdir.join('node').join('spc').join('result_spc.pklz')) |
| 298 | + loaded_result = load_resultfile( |
| 299 | + tmpdir.join('node').join('spc').join('result_spc.pklz').strpath) |
296 | 300 |
|
297 | 301 | assert result.runtime.dictcopy() == loaded_result.runtime.dictcopy()
|
298 | 302 | assert result.inputs == loaded_result.inputs
|
299 | 303 | assert result.outputs.get() == loaded_result.outputs.get()
|
| 304 | + |
| 305 | + # Test the mobility of the result file. |
| 306 | + copytree(tmpdir.join('node').strpath, tmpdir.join('node2').strpath) |
| 307 | + save_resultfile(result, tmpdir.join('node2').strpath, 'spc', rebase=True) |
| 308 | + loaded_result2 = load_resultfile( |
| 309 | + tmpdir.join('node2').join('spc').join('result_spc.pklz').strpath) |
| 310 | + |
| 311 | + assert result.runtime.dictcopy() == loaded_result2.runtime.dictcopy() |
| 312 | + assert result.inputs == loaded_result2.inputs |
| 313 | + assert loaded_result2.outputs.get() != result.outputs.get() |
| 314 | + newpath = result.outputs.out_path.replace('/node/', '/node2/') |
| 315 | + assert loaded_result2.outputs.out_path == newpath |
| 316 | + assert loaded_result2.outputs.out_tuple[0] == newpath |
| 317 | + assert loaded_result2.outputs.out_dict_path['2'] == newpath |
0 commit comments