Skip to content

Commit 08a541a

Browse files
committed
Merge branch '530_load_json_issue' into develop
2 parents 9907cd2 + c8dcc7e commit 08a541a

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
==============================
22
Changelog
33

4+
xxxx-xx-xx
5+
Release x.x.x
6+
7+
* Fixd error in load_json in util.py
8+
49
2023-07-14
510
Release 9.0.0
611

src/attributecode/util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,8 @@ def load_json(location):
277277

278278
# FIXME: this is too clever and complex... IMHO we should not try to guess the format.
279279
# instead a command line option should be provided explictly to say what is the format
280-
if isinstance(results, list):
281-
results = sorted(results)
282-
else:
280+
if not isinstance(results, list):
281+
# FIXME: I think we can remove the support of aboutcode_manager
283282
if u'aboutcode_manager_notice' in results:
284283
results = results['components']
285284
elif u'scancode_notice' in results:

tests/test_util.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,21 @@ def test_load_json(self):
375375
result = util.load_json(test_file)
376376
assert expected == result
377377

378+
def test_load_json_multi_entries(self):
379+
test_file = get_test_loc('test_util/json/multi_entries.json')
380+
expected = [dict([
381+
('about_file_path', '/load/this.ABOUT'),
382+
('about_resource', '.'),
383+
('name', 'AboutCode'),
384+
('version', '0.11.0')]),
385+
dict([
386+
('about_file_path', '/load/that.ABOUT'),
387+
('about_resource', '.'),
388+
('name', 'that')])
389+
]
390+
result = util.load_json(test_file)
391+
assert expected == result
392+
378393
def test_load_json2(self):
379394
test_file = get_test_loc('test_util/json/expected_need_mapping.json')
380395
expected = [dict(dict([
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"about_file_path": "/load/this.ABOUT",
4+
"about_resource": ".",
5+
"name": "AboutCode",
6+
"version": "0.11.0"
7+
},
8+
{
9+
"about_file_path": "/load/that.ABOUT",
10+
"about_resource": ".",
11+
"name": "that"
12+
}
13+
]

0 commit comments

Comments
 (0)