From 817af4813c165fa7f95b0726abd509759a4fb70f Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Sat, 11 May 2024 22:17:21 +0200 Subject: [PATCH] grassTask.get_param(): full match also for strings (#3582) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * script.task: Create test file grassTask.get_param() Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- python/grass/script/task.py | 3 --- python/grass/script/tests/test_script_task.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 python/grass/script/tests/test_script_task.py diff --git a/python/grass/script/task.py b/python/grass/script/task.py index 325b5640edc..eedf34738e7 100644 --- a/python/grass/script/task.py +++ b/python/grass/script/task.py @@ -148,9 +148,6 @@ def get_param(self, value, element="name", raiseError=True): if isinstance(val, (list, tuple)): if value in val: return p - elif isinstance(val, (bytes, str)): - if p[element][: len(value)] == value: - return p else: if p[element] == value: return p diff --git a/python/grass/script/tests/test_script_task.py b/python/grass/script/tests/test_script_task.py new file mode 100644 index 00000000000..6799885761e --- /dev/null +++ b/python/grass/script/tests/test_script_task.py @@ -0,0 +1,11 @@ +from grass.script.task import grassTask as gtask + + +def test_mapcalc_simple_e_name(): + gt = gtask("r.mapcalc.simple") + assert gt.get_param("e")["name"] == "e" + + +def test_mapcalc_simple_expession_name(): + gt = gtask("r.mapcalc.simple") + assert gt.get_param("expression")["name"] == "expression"