test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Side effects of self assignments #213

Closed HolQue closed 1 month ago

HolQue commented 4 months ago

The question is: What shall be the outcome of code like this?

"param" : "value",
${param} : ${param}

I assume that in the second line something existing is overwritten by itself. Therefore this line should not have any impact.

That's the case. The result is like expected:

{'param': 'value'}

Trying the same with a dictionary and a list:

"param" : {"A" : 1},
${param} : ${param}
"param" : ["A" , 1],
${param} : ${param}

Result in both cases:

Error: 'expected string or bytes-like object'!

But why is that? I would expect the same behavior like in the first example: After second line the param has same value as set in the first line.

HolQue commented 2 months ago

The code above work like expected now. But only for top level parameters. In TestsuitesManagement style it still does not work:

"params" : {"global" : {"param"  : ["A" , 1],
                        ${params.global.param} : ${params.global.param}
                       }
           }

Outcome:

'The variable '${params}['global']['param']' is not available!'

See also:

https://github.com/test-fullautomation/robotframework-testsuitesmanagement/issues/253

HolQue commented 2 months ago

Removed "successfully tested" label because of https://github.com/test-fullautomation/python-jsonpreprocessor/issues/213#issuecomment-1994356229

HolQue commented 2 months ago

Covered by self test JPP_1800

namsonx commented 1 month ago

Hello Holger,

I pushed new commit to stabi branch to fix this issue, I also enabled test case JPP_1800.

Thank you, Son

HolQue commented 1 month ago

Retest successful. Issue can be closed.

test-fullautomation commented 1 month ago

integrated in RobotFramework AIO 0.11.0