Skip to content

Commit

Permalink
fix: resolve LANG replacement bug when it contains carriage returns (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rgonalo committed May 5, 2023
1 parent 4a2f6be commit 86ddb08
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -8,6 +8,7 @@ v3.0.1

- Allow to search in `context.storage` using `[CONTEXT:a.b.c]` replacement when `before_feature` method is not used
- Execute after scenario methods also when a scenario is skipped to assure that scenario preconditions are cleaned
- Fix `[LANG:key]` replacement bug when it contains carriage returns

v3.0.0
------
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Expand Up @@ -8,3 +8,4 @@ flake8~=5.0; python_version < '3.8'
flake8~=6.0; python_version >= '3.8'
build~=0.10
wheel~=0.40
twine~=4.0
5 changes: 4 additions & 1 deletion toolium/test/utils/test_dataset_map_param.py
Expand Up @@ -117,6 +117,7 @@ def test_a_lang_param():
('home.unknown'),
('unknown!'),
('home.unknown!'),
('home.unknown\n'),
]


Expand All @@ -129,7 +130,9 @@ def test_a_lang_param_unknown(lang_key):
dataset.language = "es"
with pytest.raises(KeyError) as excinfo:
map_param(f"[LANG:{lang_key}]")
assert f'"Mapping chain \'{lang_key}\' not found in the language properties file"' == str(excinfo.value)
# Get exception message updating \n
exc_message = str(excinfo.value).replace('\\n', '\n')
assert f'"Mapping chain \'{lang_key}\' not found in the language properties file"' == exc_message


def test_a_toolium_param():
Expand Down
2 changes: 1 addition & 1 deletion toolium/utils/dataset.py
Expand Up @@ -473,7 +473,7 @@ def _get_mapping_type_and_key(param):
"""
types = ["CONF", "LANG", "POE", "ENV", "BASE64", "TOOLIUM", "CONTEXT", "FILE"]
for type in types:
match_group = re.match(r"\[%s:(.*)\]" % type, param)
match_group = re.match(r"\[%s:([^\[\]]*)\]" % type, param)
if match_group:
return type, match_group.group(1)
return None, None
Expand Down

0 comments on commit 86ddb08

Please sign in to comment.