Skip to content

Commit b691f90

Browse files
committed
ENH: reincarnate the paranoid test of a json tuned up with regular expressions
Fixes #104
1 parent 8fefd5c commit b691f90

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

heudiconv/utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,16 @@ def json_dumps_pretty(j, indent=2, sort_keys=True):
226226
js_ = re.sub(' *("?[-+.0-9e]+"?)[ \n]*', r' \1', js_)
227227
# no spaces after [
228228
js_ = re.sub('\[ ', '[', js_)
229-
j_ = json.loads(js_)
230-
# Removed assert as it does not do any floating point comparison
231-
#assert(j == j_)
229+
# the load from the original dump and reload from tuned up
230+
# version should result in identical values since no value
231+
# must be changed, just formatting.
232+
j_just_reloaded = json.loads(js)
233+
j_tuned = json.loads(js_)
234+
235+
assert j_just_reloaded == j_tuned, \
236+
"Values differed when they should have not. "\
237+
"Report to the heudiconv developers"
238+
232239
return js_
233240

234241

@@ -402,4 +409,4 @@ def clear_temp_dicoms(item_dicoms):
402409

403410
def file_md5sum(filename):
404411
with open(filename, 'rb') as f:
405-
return hashlib.md5(f.read()).hexdigest()
412+
return hashlib.md5(f.read()).hexdigest()

0 commit comments

Comments
 (0)