File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ import json
1
2
import os
2
3
import os .path as op
3
4
from heudiconv .utils import (
4
5
get_known_heuristics_with_descriptions ,
5
6
get_heuristic_description ,
6
7
load_heuristic ,
7
- json_dumps_pretty )
8
+ json_dumps_pretty ,
9
+ load_json )
8
10
9
11
import pytest
10
12
from .utils import HEURISTICS_PATH
@@ -58,4 +60,17 @@ def test_json_dumps_pretty():
58
60
'Mar 3 2017 10:46:13 by eja'
59
61
# just the date which reveals the issue
60
62
# tstr = 'Mar 3 2017 10:46:13 by eja'
61
- assert pretty ({'WipMemBlock' : tstr }) == '{\n "WipMemBlock": "%s"\n }' % tstr
63
+ assert pretty ({'WipMemBlock' : tstr }) == '{\n "WipMemBlock": "%s"\n }' % tstr
64
+
65
+
66
+ def test_load_json (tmp_path , capsys ):
67
+ # test invalid json
68
+ content = "I'm Jason Bourne"
69
+ fname = "invalid.json"
70
+ json_file = tmp_path / fname
71
+ json_file .write_text (content )
72
+
73
+ with pytest .raises (json .JSONDecodeError ):
74
+ load_json (json_file )
75
+ captured = capsys .readouterr ()
76
+ assert fname in captured .out
You can’t perform that action at this time.
0 commit comments