Skip to content

Commit d3f3f49

Browse files
committed
add tests
1 parent e681974 commit d3f3f49

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

nipype/interfaces/tests/test_base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import tempfile
1111
import shutil
1212
import warnings
13+
import simplejson as json
1314

1415
from nipype.testing import (assert_equal, assert_not_equal, assert_raises,
1516
assert_true, assert_false, with_setup, package_check,
@@ -499,15 +500,23 @@ def __init__(self, **inputs):
499500

500501
# test get hashval in a complex interface
501502
from nipype.interfaces.ants import Registration
502-
tsthash = Registration(from_file=example_data('smri_ants_registration_settings.json'))
503+
settings = example_data(example_data('smri_ants_registration_settings.json'))
504+
with open(settings) as setf:
505+
data_dict = json.load(setf)
506+
tsthash = Registration(from_file=settings)
507+
yield assert_all_true, data_dict, tsthash.inputs.get_traitsfree()
503508
hashed_inputs, hashvalue = tsthash.inputs.get_hashval(hash_method='timestamp')
504-
# yield assert_equal, hashed_inputs, [('input1', 12), ('input3', True), ('input4', 'some string')]
505-
yield assert_equal, hashvalue, '9ab944cbccba61475becb9eac65052af'
509+
# yield assert_equal, hashvalue, '9ab944cbccba61475becb9eac65052af'
506510

507511
def assert_not_raises(fn, *args, **kwargs):
508512
fn(*args, **kwargs)
509513
return True
510514

515+
def assert_all_true(ref_dict, tst_dict):
516+
for key, value in list(ref_dict.items()):
517+
if tst_dict[key] != value:
518+
return False
519+
return True
511520

512521
def test_input_version():
513522
class InputSpec(nib.TraitedSpec):

0 commit comments

Comments
 (0)