10000 Fix error in descendant match for list · adamncasey/python-jsonpath-rw@be6d379 · GitHub
[go: up one dir, main page]

Skip to content

Commit be6d379

Browse files
c 8000 ommitted
Fix error in descendant match for list
1 parent ffb6cc7 commit be6d379

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

jsonpath_rw/jsonpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ def match_recursively(datum):
286286
# Manually do the * or [*] to avoid coercion and recurse just the right-hand pattern
287287
if isinstance(datum.value, list):
288288
recursive_matches = [submatch
289-
for submatch in match_recursively(DatumInContext(datum.value[i], context=datum, path=Index(i)))
290-
for i in xrange(0, len(datum.value))]
289+
for i in xrange(0, len(datum.value))
290+
for submatch in match_recursively(DatumInContext(datum.value[i], context=datum, path=Index(i)))]
291291

292292
elif isinstance(datum.value, dict):
293293
recursive_matches = [submatch

tests/test_jsonpath.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def test_child_value(self):
121121
('foo.baz.bizzle', {'foo': {'baz': {'bizzle': 5}}}, [5])])
122122

123123
def test_descendants_value(self):
124-
self.check_cases([('foo..baz', {'foo': {'baz': 1, 'bing': {'baz': 2}}}, [1, 2] )])
124+
self.check_cases([
125+
('foo..baz', {'foo': {'baz': 1, 'bing': {'baz': 2}}}, [1, 2] ),
126+
('foo..baz', {'foo': [{'baz': 1}, {'baz': 2}]}, [1, 2] ),
127+
])
125128

126129
#
127130
# Check that the paths for the data are correct.

0 commit comments

Comments
 (0)
0