From 5a86e498d2fb870aabde81b8829e737d8bfc082c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sun, 4 Jan 2026 14:30:49 +0100 Subject: [PATCH] Changed expression evaluation opening and closing pattern. --- .../source/test_items/items_common_attributes.rst | 4 ++-- doc/manual/sphinx/source/tum_syntax.rst | 8 ++++---- src/testium/interpreter/utils/params.py | 4 ++-- test/validation/items/common/results/test.tum | 4 ++-- test/validation/items/expanse/param.yaml | 2 +- test/validation/items/expanse/test.tum | 12 ++++++------ test/validation/param.yaml | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/manual/sphinx/source/test_items/items_common_attributes.rst b/doc/manual/sphinx/source/test_items/items_common_attributes.rst index 6ad9137..22c2f24 100644 --- a/doc/manual/sphinx/source/test_items/items_common_attributes.rst +++ b/doc/manual/sphinx/source/test_items/items_common_attributes.rst @@ -195,8 +195,8 @@ Export attribute key: - GID-1510554_step_1 report: - reported_list: <@ random.sample(range(0,20), k=10) @> - reported_float: <@ math.sqrt(float(1)) @> + reported_list: @| random.sample(range(0,20), k=10) | + reported_float: @| math.sqrt(float(1)) | reported_str: This is my reported sentence diff --git a/doc/manual/sphinx/source/tum_syntax.rst b/doc/manual/sphinx/source/tum_syntax.rst index f5e8c6b..b9029b5 100644 --- a/doc/manual/sphinx/source/tum_syntax.rst +++ b/doc/manual/sphinx/source/tum_syntax.rst @@ -63,7 +63,7 @@ The parameter file can be specified in the `.tum` file root: parameter1: value1 parameter2: 1234 - parameter3: <@ 12.34 * 2 @> + parameter3: @| 12.34 * 2 | parameter4: - $(parameter1) - $(parameter3) @@ -202,7 +202,7 @@ The variable substitution is recursive and checks all the occurrences of the ``$(x)`` pattern in a string. It is also possible to perform evaluation of python substrings during parameters passing. -It is done by using the ``<@ expr @>`` pattern in a string. +It is done by using the ``@| expr |`` pattern in a string. `expr` may then be a correct python expression. Below are illustrated simple and more complicated cases of expansion and evaluation depending on @@ -215,10 +215,10 @@ their pattern. name: Dynamic variables expansion key: $(test)_PASS values: - - expanse_select: <@"$(expanse_select)".replace("o", "a")@> + - expanse_select: @|"$(expanse_select)".replace("o", "a")| - expanse_index: $(expanse_index_$(expanse_select)) - expanse_table: $(expanse_table_$(expanse_select)) - - expanse_eval: <@$(expanse_index) == 1@> + - expanse_eval: @|$(expanse_index) == 1| Test Items -------------------- diff --git a/src/testium/interpreter/utils/params.py b/src/testium/interpreter/utils/params.py index ba400aa..f34c0eb 100644 --- a/src/testium/interpreter/utils/params.py +++ b/src/testium/interpreter/utils/params.py @@ -313,12 +313,12 @@ def _preprocess_string(value, parent=None): def _eval_param(value): """This function parses a string value to check if patterns corresponding - to <@xxx@ exists. + to @|xxx| exists. When this kind of pattern is found, an attempt to evaluate its content is done. If it is not evaluable, not replaced. """ - return _parse_and_process("<@", "@>", value, evaluate) + return _parse_and_process("@|", "|", value, evaluate) def _process_recursively(func, param_value, *fparams): diff --git a/test/validation/items/common/results/test.tum b/test/validation/items/common/results/test.tum index 8a63425..3d333a9 100644 --- a/test/validation/items/common/results/test.tum +++ b/test/validation/items/common/results/test.tum @@ -138,7 +138,7 @@ - py_func: name: Return True expect False but no_fail expansed - no_fail: <@ bool(0) == False @> + no_fail: @| bool(0) == False | key: $(test)_PASS file: $(test_path)$(psep)results$(psep)results.py func_name: echo @@ -147,7 +147,7 @@ - py_func: name: Return True expect False but no_fail expansed (must fail) - no_fail: <@ bool(1) == False @> + no_fail: @| bool(1) == False | key: $(test)_FAIL file: $(test_path)$(psep)results$(psep)results.py func_name: echo diff --git a/test/validation/items/expanse/param.yaml b/test/validation/items/expanse/param.yaml index ad62755..c96c18d 100644 --- a/test/validation/items/expanse/param.yaml +++ b/test/validation/items/expanse/param.yaml @@ -9,4 +9,4 @@ expanse_index_blo: 1 expanse_index: $(expanse_index_$(expanse_select)) expanse_table: $(expanse_table_$(expanse_select)) -expanse_eval: <@$(expanse_index) == 1@> +expanse_eval: @|$(expanse_index) == 1| diff --git a/test/validation/items/expanse/test.tum b/test/validation/items/expanse/test.tum index 7509ead..4ad40a2 100644 --- a/test/validation/items/expanse/test.tum +++ b/test/validation/items/expanse/test.tum @@ -10,10 +10,10 @@ name: Dynamic variables expansion key: $(test)_PASS values: - - expanse_select: <@"$(expanse_select)".replace("o", "a")@> + - expanse_select: @|"$(expanse_select)".replace("o", "a")| - expanse_index: $(expanse_index_$(expanse_select)) - expanse_table: $(expanse_table_$(expanse_select)) - - expanse_eval: <@$(expanse_index) == 1@> + - expanse_eval: @|$(expanse_index) == 1| - check: name: Check variables expansion is correct (PASS) @@ -33,7 +33,7 @@ - var4: blo - expanse_var_bla: 3 - expanse_blo_var: 5 - - expanse_complex: <@<@$(expanse_$(var2)_$(var3))*6@> + <@4*$($(var1)_$(var4)_$(var2))@>@> + - expanse_complex: @|@|$(expanse_$(var2)_$(var3))*6| + @|4*$($(var1)_$(var4)_$(var2))|| - check: name: Check complex variables expansion is correct (PASS) @@ -50,10 +50,10 @@ - expanse_var_2: 6 - expanse_object: [ - { a: $(expanse_var_2), $(expanse_key): <@2**3@> }, + { a: $(expanse_var_2), $(expanse_key): @|2**3| }, { - '<@"bla".replace("a", "o")@>': - [<@$(expanse_var)*$(expanse_var_2)@>, 25], + '@|"bla".replace("a", "o")|': + [@|$(expanse_var)*$(expanse_var_2)|, 25], }, ] diff --git a/test/validation/param.yaml b/test/validation/param.yaml index d6843eb..1dea0f5 100644 --- a/test/validation/param.yaml +++ b/test/validation/param.yaml @@ -1,5 +1,5 @@ # All sub directory in items are evaluated as a list -items: <@ [os.path.basename(f.path) for f in os.scandir(os.path.join(r"$(test_directory)", "items")) if f.is_dir()] @> +items: @| [os.path.basename(f.path) for f in os.scandir(os.path.join(r"$(test_directory)", "items")) if f.is_dir()] | # - common # - check # - console