Closed HolQue closed 1 month ago
Hi Son, behaviour should be same like python does. So "by reference" would be required. Thank you, Thomas
Hello Thomas, Hello Holger,
If we refer "by reference" like Python dose, so there is nothing to do with current behavior of JP as Holger mentioned in ticket.
I use many copy.deepcopy
to handle other stuffs such as checking dict
or list
in for
or while
loop, I always delete temporary objects from copy.deepcopy
once checking completed.
Thank you, Son
Again I extended the code example from above (by a fourth line). Unfortunately this causes an error.
The following JSON code
testdict1
with some subkeys implicitly,testdict2
),testdict1
and also testdict2
${testdict1.subKey1.subKey2} : 1,
"testdict2" : ${testdict1},
${testdict2.subKey1.subKey2} : 2,
${testdict1.subKey1.subKey2} : 3
Result:
{'testdict1': {'subKey1': {'subKey2': 2}},
'testdict2': {'subKey1': {'subKey2': 2}}}
But I would expect value 3 in both cases (instead of 2
).
Covered by JPP_1900
Hello Holger,
I fixed and uncovered test case ID JPP_1900, the commit was pushed into stabi branch.
Thank you, Son
Retest successful. Issue can be closed.
integrated in RobotFramework AIO 0.11.0
In addition to
https://github.com/test-fullautomation/python-jsonpreprocessor/issues/210
I extend the code by a third line in which I recreate
testdict2
(instead oftestdict1
):The result is:
The question is: How shall this assignment work:
"testdict2" : ${testdict1},
"by reference" or "by value"?
In pure Python it would be: "by reference". But the JsonPreprocessor code contains a lot of
copy.deepcopy()
calls. And this is an indicator for "by value".Because of this makes a difference and because of it is necessary to explain this in documentation and to be able to design self test cases I would prefer to have this clarified: What is the desired value passing method in JsonPreprocessor: "by reference" or "by value"?
If "by reference", the result above is correct. The changed value of
subKey2
is visible in bothtestdict1
andtestdict2
. But if "by value", the result above is not correct. The expectation in this case would be to have two different objects that are independent from each other: