From 4be0af413ee205f08d675b3a8872366be1162ff7 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Sun, 29 Mar 2020 12:03:36 +0100
Subject: [PATCH] TEST: test bad json

---
 tests/test_image.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/test_image.py b/tests/test_image.py
index 06801c11f..75ec686a9 100644
--- a/tests/test_image.py
+++ b/tests/test_image.py
@@ -1414,11 +1414,23 @@ def test_loadMeta_nonBids():
         with open(op.join('data', 'dataset_description.json'), 'wt') as f:
             pass
 
-
         img = fslimage.Image(imgfile, loadMeta=True)
         assert list(img.metaKeys()) == []
 
 
+def test_loadMeta_badJSON():
+    with tempdir():
+        make_image('image.nii.gz')
+
+        # spurious comma after b:2
+        with open('image.json', 'wt') as f:
+            f.write('{"a" : 1, "b" : 2,}')
+
+        # bad json should not cause failure
+        img = fslimage.Image('image.nii.gz', loadMeta=True)
+
+        assert list(img.metaKeys()) == []
+
 
 def test_loadMetadata():
     with tempdir():
-- 
GitLab