|
10 | 10 | import tempfile
|
11 | 11 | import shutil
|
12 | 12 | import warnings
|
| 13 | +import simplejson as json |
13 | 14 |
|
14 | 15 | from nipype.testing import (assert_equal, assert_not_equal, assert_raises,
|
15 | 16 | assert_true, assert_false, with_setup, package_check,
|
@@ -499,15 +500,23 @@ def __init__(self, **inputs):
|
499 | 500 |
|
500 | 501 | # test get hashval in a complex interface
|
501 | 502 | 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() |
503 | 508 | 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' |
506 | 510 |
|
507 | 511 | def assert_not_raises(fn, *args, **kwargs):
|
508 | 512 | fn(*args, **kwargs)
|
509 | 513 | return True
|
510 | 514 |
|
| 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 |
511 | 520 |
|
512 | 521 | def test_input_version():
|
513 | 522 | class InputSpec(nib.TraitedSpec):
|
|
0 commit comments