From 80d2f53e25c922a6d926748e7b2a9cb2aa1dafb6 Mon Sep 17 00:00:00 2001 From: Patricia Roman Sanchez Date: Tue, 8 Oct 2024 12:24:50 +0200 Subject: [PATCH] Fix test issue --- toolium/test/utils/test_dataset_map_param_context.py | 7 ++++--- toolium/test/utils/test_dataset_replace_param.py | 2 +- toolium/utils/dataset.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/toolium/test/utils/test_dataset_map_param_context.py b/toolium/test/utils/test_dataset_map_param_context.py index d13442eb..3fda8916 100644 --- a/toolium/test/utils/test_dataset_map_param_context.py +++ b/toolium/test/utils/test_dataset_map_param_context.py @@ -481,9 +481,10 @@ class Context(object): } ] } - dataset.behave_context = context - assert map_param("[CONTEXT:list.cmsScrollableActions.-5.id]") - + with pytest.raises(Exception) as excinfo: + map_param("[CONTEXT:list.cmsScrollableActions.-5.id]") + assert "IndexError: list index out of range" == str(excinfo.value) + def test_a_context_param_list_oob_index(): """ diff --git a/toolium/test/utils/test_dataset_replace_param.py b/toolium/test/utils/test_dataset_replace_param.py index bec1eb64..59f413c0 100644 --- a/toolium/test/utils/test_dataset_replace_param.py +++ b/toolium/test/utils/test_dataset_replace_param.py @@ -377,7 +377,7 @@ def test_replace_param_dict(): def test_replace_param_dict_json_format(): param = replace_param('[DICT:{"key": "value", "key_2": true}]') - assert param == '{"key": "value", "key_2": true}' + assert param == '{"key": "value", "key_2": True}' param = replace_param('[DICT:{"key": "value", "key_2": null}]') assert param == '{"key": "value", "key_2": null}' diff --git a/toolium/utils/dataset.py b/toolium/utils/dataset.py index 3c4e4346..b7ac78f7 100644 --- a/toolium/utils/dataset.py +++ b/toolium/utils/dataset.py @@ -259,7 +259,7 @@ def _replace_param_transform_string(param): def _update_param_transform_string(type_mapping_match_group): """ Transform param value according to the specified prefix. - Available transformations: STR, UPPER, LOWER, REPLACE, TITLE + Available transformations: STR, UPPER, LOWER, REPLACE, TITLE, ROUND :param type_mapping_match_group: match group :return: return the string with the replaced param @@ -281,7 +281,7 @@ def _update_param_transform_string(type_mapping_match_group): type_mapping_match_group.group(2).title()))) elif type_mapping_match_group.group(1) == 'ROUND': replace_params = type_mapping_match_group.group(2).split('::') - replace_param = f"{round(float(replace_params[0]), int(replace_params[1])):.{int(replace_params[1])} f }" + replace_param = f"{round(float(replace_params[0]), int(replace_params[1])):.{int(replace_params[1])}f}" return replace_param