Skip to content

Commit 9e155df

Browse files
committed
building in difflib to see whats going on
1 parent 50a480e commit 9e155df

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

nibabel/tests/test_scripts.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from glob import glob
1515

1616
import numpy as np
17+
import difflib
1718

1819
from ..tmpdirs import InTemporaryDirectory
1920
from ..loadsave import load
@@ -72,9 +73,47 @@ def check_nib_diff_examples(opts=[], hdrs_str="", other_str=""):
7273
for f in ('example4d.nii.gz', 'standard.nii.gz')]
7374
fnames2 = [pjoin(DATA_PATH, f)
7475
for f in ('example4d.nii.gz', 'example4d.nii.gz')]
75-
hash1 = str(hash(fnames[0]))
76-
hash2 = str(hash(fnames[1]))
7776
code, stdout, stderr = run_command(['nib-diff'] + fnames, check_code=False)
77+
hi = difflib.context_diff(stdout, "Field " + "{:<45}".format("example4d.nii.gz") + "{:<45}".format("standard.nii.gz")
78+
+ "\n" + "regular b'r' b'' "
79+
" " + "\n" + "dim_info 57 "
80+
" 0 "
81+
" "
82+
" " + "\n"
83+
"dim [4, 128, 96, 24, 2, 1, 1, 1] [3, 4, 5, 7, 1, 1, 1, 1] "
84+
+ "\n" + "datatype 4 2 "
85+
" " + "\n" + "bitpix 16 8 "
86+
" " + "\n" + "pixdim [-1.0, 2.0, 2.0, "
87+
"2.1999991, 2000.0, 1.0, 1.0,"
88+
" 1.0][1.0, 1.0, 3.0, 2.0, "
89+
"1.0, 1.0, 1.0, 1.0] " +
90+
"\n" + "slice_end 23 0 "
91+
" " + "\n" + "xyzt_units 10 0 "
92+
" " + "\n" + "cal_max 1162.0 "
93+
" 0.0 "
94+
" " + "\n" +
95+
"descrip b'FSL3.3\\x00 v2.25 NIfTI-1 Single file format'b'' "
96+
" \n" + "qform_code 1 0 "
97+
" " + "\n" + "sform_code 1 2 "
98+
" \n" +"quatern_b -1.9451068140294884e-26 "
99+
" 0.0 "
100+
" " + "\n" +
101+
"quatern_c -0.9967085123062134 0.0 "
102+
+ "\n" + "quatern_d -0.0810687392950058 0.0 "
103+
" " + "\n" + "qoffset_x 117.8551025390625 0.0 "
104+
" " + "\n" + "qoffset_y -35.72294235229492"
105+
" 0."
106+
"0 "
107+
" " + "\n" +
108+
"qoffset_z -7.248798370361328 0.0 "
109+
+ "\n" + "srow_x [-2.0, 6.7147157e-19, 9.0810245e-18, 117.8551][1.0, 0.0, 0.0, 0.0] "
110+
" " + "\n" + "srow_y [-6.7147157e-19, 1.9737115, -0.35552824, -35.722942][0.0, 3"
111+
".0, 0.0, 0.0] " + "\n" +
112+
"srow_z [8.2554809e-18, 0.32320762, 2.1710818, -7.2487984][0.0, 0.0, 2.0, 0.0] "
113+
" " + "\n" + "DATA: These files are different.\nChecksum b0abbc49 "
114+
+ " 0a2576dd")
115+
delta = ''.join(hi)
116+
print(delta)
78117
assert_equal(stdout, "Field " + "{:<45}".format("example4d.nii.gz") + "{:<45}".format("standard.nii.gz")
79118
+ "\n" + "regular b'r' b'' "
80119
" " + "\n" + "dim_info 57 "

0 commit comments

Comments
 (0)