Skip to content

Commit 8cefc0b

Browse files
kurtmckeemichaelmior
authored andcommitted
Add a test case
1 parent 7987969 commit 8cefc0b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/test_jsonpath.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import copy
2+
13
import pytest
24

35
from jsonpath_ng.ext.parser import parse as ext_parse
@@ -124,6 +126,16 @@ def test_datumincontext_in_context_nested():
124126
3,
125127
{"foo": {"bar": 3, "flag": 1}, "baz": {"bar": 2}},
126128
),
129+
#
130+
# Lambdas
131+
# -------
132+
#
133+
(
134+
"foo[*].baz",
135+
{'foo': [{'baz': 1}, {'baz': 2}]},
136+
lambda x, y, z: x + 1,
137+
{'foo': [{'baz': 2}, {'baz': 3}]}
138+
),
127139
)
128140

129141

@@ -133,7 +145,8 @@ def test_datumincontext_in_context_nested():
133145
)
134146
@parsers
135147
def test_update(parse, expression, data, update_value, expected_value):
136-
result = parse(expression).update(data, update_value)
148+
data_copy = copy.deepcopy(data)
149+
result = parse(expression).update(data_copy, update_value)
137150
assert result == expected_value
138151

139152

0 commit comments

Comments
 (0)