Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified JsonPreprocessor/JsonPreprocessor.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ This feature is an option. If the user does not define the parameter ``keyPatter

| ``\"A\" : [1,2,3],``
| ``\"B\" : [4,5,6],``
| ``\"C\" : <<eval ${A} + ${B}>>``
| ``\"C\" : <<${A} + ${B}>>``

*Result*

Expand Down
15 changes: 13 additions & 2 deletions packagedoc/additional_docs/The JSONP format.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ \section{Python inline code}
\begin{pythoncode}
"A" : [1,2,3],
"B" : [4,5,6],
"C" : <\textless{}\textless{}>eval ${A} + ${B}<\textgreater{}\textgreater{}>
"C" : <\textless{}\textless{}>${A} + ${B}<\textgreater{}\textgreater{}>
\end{pythoncode}

The expression \pcode{$\{A\} + $\{B\}} is handled as Python inline code. It is possible to use dollar operator expressions
Expand All @@ -1405,12 +1405,23 @@ \section{Python inline code}
The syntax of Python inline code is:

\begin{pythoncode}
<\textless{}\textless{}>eval <(\emph{Python expression})><\textgreater{}\textgreater{}>
<\textless{}\textless{}><(\emph{Python expression})><\textgreater{}\textgreater{}>
\end{pythoncode}

The usage of Python inline code is limited to the right hand side of the colon (\emph{key values}).
This feature cannot be used to create key names.

The Python inline code syntax cannot be used within strings:

\begin{pythoncode}
"param" : "The value is <\textless{}\textless{}><(\emph{Python expression})><\textgreater{}\textgreater{}>"
\end{pythoncode}







% --------------------------------------------------------------------------------------------------------------

1 change: 0 additions & 1 deletion test/JPP_TestUsecases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,3 @@ JPP_2055|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing s
JPP_2056|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (7)
JPP_2057|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (8)
JPP_2058|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (9)
JPP_2100|INLINE_CODE|GOODCASE|JSON file containing Python inline code
37 changes: 1 addition & 36 deletions test/JPP_TestUsecases.html
Original file line number Diff line number Diff line change
Expand Up @@ -6737,47 +6737,12 @@
</i></font></td>


</tr>
<tr valign="middle" align="left">
<td colspan="1" valign="center" bgcolor="#F5F5F5" align="right">
<font size="2" face="Arial" color="#FF0000">
<b>
203
</b></font></td>

<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
<font size="2" face="Arial" color="#595959">
<b>
<a target="_blank" href="https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/test/testfiles/jpp-test_config_2100.jsonp">JPP_2100</a>
</b></font></td>

<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
<font size="2" face="Arial" color="#4169E1">
INLINE_CODE
</font></td>

<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
<font size="2" face="Arial" color="#008000">
GOODCASE
</font></td>

<td colspan="1" valign="center" bgcolor="#F5F5F5" align="left">
<font size="2" face="Arial" color="#595959"><i>
<b>JSON file containing Python inline code</b><br>
Expected: JsonPreprocessor returns expected values
<br>
https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454
<br>
Test needs to be adapted after bugfixing
</i></font></td>


</tr>

</tbody></table></div>
<div>&nbsp;</div>
<hr width="100%" color="#FF8C00" align="center">
<div align="center"><font size="2" color="#27408B">Generated: 18.07.2025 - 16:02:56</font></div>
<div align="center"><font size="2" color="#27408B">Generated: 05.08.2025 - 16:52:10</font></div>
<div>&nbsp;</div>
</body></html>

16 changes: 1 addition & 15 deletions test/JPP_TestUsecases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2125,19 +2125,5 @@ Test Use Cases

----

* **Test JPP_2100**

[INLINE_CODE / GOODCASE]

**JSON file containing Python inline code**

Expected: JsonPreprocessor returns expected values

*Comment: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454*

*Hint: Test needs to be adapted after bugfixing*

----

Generated: 18.07.2025 - 16:02:56
Generated: 05.08.2025 - 16:52:10

8 changes: 1 addition & 7 deletions test/JPP_TestUsecases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,5 @@ Test JPP_2058 / PARAMETER_SCOPE / BADCASE
Description: JSON file containing a parameter with missing scope (9)
Expectation: No values are returned, and JsonPreprocessor throws an exception
------------------------------------------------------------------------------------------------------------------------
Test JPP_2100 / INLINE_CODE / GOODCASE
Description: JSON file containing Python inline code
Expectation: JsonPreprocessor returns expected values
Comment....: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454
Hint.......: Test needs to be adapted after bugfixing
------------------------------------------------------------------------------------------------------------------------
Generated: 18.07.2025 - 16:02:56
Generated: 05.08.2025 - 16:52:10

4 changes: 2 additions & 2 deletions test/component_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#
# --------------------------------------------------------------------------------------------------------------
#
VERSION = "0.61.0"
VERSION_DATE = "18.07.2025"
VERSION = "0.62.0"
VERSION_DATE = "05.08.2025"
#
# --------------------------------------------------------------------------------------------------------------
#TM***
Expand Down
40 changes: 0 additions & 40 deletions test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py

This file was deleted.

147 changes: 109 additions & 38 deletions test/testconfig/TestConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
# --------------------------------------------------------------------------------------------------------------
#
# 18.07.2025
# 05.08.2025
#
# !!! Temporarily tests are deactivated by the following line commented out:
# # # listofdictUsecases.append(dictUsecase)
Expand Down Expand Up @@ -4427,50 +4427,121 @@
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2100"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with simple data types"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Test needs to be adapted after bugfixing"
dictUsecase['HINT'] = "Issue because of 'eval' still required"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2100.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
[DOTDICT] (18/1) > {A} [INT] : 0
[DOTDICT] (18/2) > {B} [INT] : 1
[DOTDICT] (18/3) > {L1} [LIST] (3/1) > [INT] : 1
[DOTDICT] (18/3) > {L1} [LIST] (3/2) > [INT] : 2
[DOTDICT] (18/3) > {L1} [LIST] (3/3) > [INT] : 3
[DOTDICT] (18/4) > {L2} [LIST] (3/1) > [INT] : 4
[DOTDICT] (18/4) > {L2} [LIST] (3/2) > [INT] : 5
[DOTDICT] (18/4) > {L2} [LIST] (3/3) > [INT] : 6
[DOTDICT] (18/5) > {kA} [STR] : 'kA'
[DOTDICT] (18/6) > {kB} [STR] : 'kB'
[DOTDICT] (18/7) > {D1} [DOTDICT] (2/1) > {kA} [STR] : 'vA'
[DOTDICT] (18/7) > {D1} [DOTDICT] (2/2) > {kB} [STR] : 'vB'
[DOTDICT] (18/8) > {choice} [BOOL] : True
[DOTDICT] (18/9) > {value01} [INT] : 10
[DOTDICT] (18/10) > {value02} [LIST] (2/1) > [INT] : 1
[DOTDICT] (18/10) > {value02} [LIST] (2/2) > [INT] : 2
[DOTDICT] (18/11) > {value04} [INT] : 4
[DOTDICT] (18/12) > {code04} [STR] : '0 if True else 1'
[DOTDICT] (18/13) > {value04b} [INT] : 4
[DOTDICT] (18/14) > {value05} [INT] : 5
[DOTDICT] (18/15) > {code05} [STR] : '0 if not True else 1'
[DOTDICT] (18/16) > {value05b} [INT] : 5
[DOTDICT] (18/17) > {values01} [DOTDICT] (3/1) > {kA} [STR] : 'A'
[DOTDICT] (18/17) > {values01} [DOTDICT] (3/2) > {kB} [INT] : 0
[DOTDICT] (18/17) > {values01} [DOTDICT] (3/3) > {kC} [STR] : 'Z'
[DOTDICT] (18/18) > {values02} [LIST] (4/1) > [INT] : 1
[DOTDICT] (18/18) > {values02} [LIST] (4/2) > [INT] : 2
[DOTDICT] (18/18) > {values02} [LIST] (4/3) > [INT] : 3
[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/1) > [INT] : 4
[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/2) > [INT] : 5
[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/3) > [INT] : 6
[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/4) > [INT] : 1
[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/5) > [INT] : 2
[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/6) > [INT] : 3
"""
listofdictUsecases.append(dictUsecase)
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2101"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with composite data types"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2101.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2102"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with simple conditions"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2102.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2103"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code within lists and dictionaries"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2103.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2104"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code as list index and dictionary key"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2104.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2105"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code in more complex scenarios"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2105.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2106"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with slicing"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required; slicing still banned"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2106.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_2107"
dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with import paths"
dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values"
dictUsecase['SECTION'] = "INLINE_CODE"
dictUsecase['SUBSECTION'] = "GOODCASE"
dictUsecase['HINT'] = "Issue because of 'eval' still required; entire import interpreted as path"
dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2107.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None
dictUsecase['EXPECTEDRETURN'] = """
"""
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
40 changes: 8 additions & 32 deletions test/testfiles/jpp-test_config_2100.jsonp
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,12 @@
// limitations under the License.
//**************************************************************************
{
// Test needs to be adapted after bugfixing
// https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454
//
"A" : 0,
"B" : 1,
"L1" : [1,2,3],
"L2" : [4,5,6],
"kA" : "kA",
"kB" : "kB",
"D1" : {"kA" : "vA", "kB" : "vB"},
"choice" : True,
//
"value01" : <<eval 10>>,
"value02" : <<eval [1,2]>>,
// !err! "value03" : <<eval {"A" : 1, "B" : 2}>>,
//
"value04" : <<eval (${A} if ${choice} else ${B}) + 4>>,
"code04" : "${A} if ${choice} else ${B}",
"value04b" : <<eval (${code04}) + 4>>,
"value05" : <<eval (${A} if not ${choice} else ${B}) + 4>>,
"code05" : "${A} if not ${choice} else ${B}",
"value05b" : <<eval (${code05}) + 4>>,
//
"values01" : {"kA" : "A",
"kB" : <<eval ${A} if ${choice} else ${B}>>,
"kC" : "Z"},
//
"values02" : <<eval ${L1} + [${L2} + ${L1}]>>
//
// !err! "value06" : ${L1}[<<eval ${A} if ${choice} else ${B}>>]
//
// !err! "value07" : ${D1}[<<eval "${kA}" if ${choice} else "${kB}">>]
// simple data types
"value1" : <<"ABC">>,
"value2" : <<25>>,
"value3" : <<2.5>>,
"value4" : <<True>>,
"value5" : <<None>>,
"value6" : <<null>>,
"value7" : <<false>>
}
Loading