From 751bf22a6bccd1acbac7ee1b76ee582c0f0b195d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 25 Mar 2022 18:54:07 +0100 Subject: [PATCH] Python : Make sure an empty list will be received as empty list See https://github.com/OPM/ResInsight/issues/8508 Python code linting changes detected by black --- GrpcInterface/Python/rips/pdmobject.py | 3 +++ GrpcInterface/Python/rips/tests/test_summary_cases.py | 1 + 2 files changed, 4 insertions(+) diff --git a/GrpcInterface/Python/rips/pdmobject.py b/GrpcInterface/Python/rips/pdmobject.py index e919cd96c1..89d2c9404e 100644 --- a/GrpcInterface/Python/rips/pdmobject.py +++ b/GrpcInterface/Python/rips/pdmobject.py @@ -223,6 +223,9 @@ class PdmObjectBase: def __makelist(self, list_string): list_string = list_string.lstrip("[") list_string = list_string.rstrip("]") + if not list_string: + # Return empty list if empty string. Otherwise, the split function will return [''] + return [] strings = list_string.split(", ") values = [] for string in strings: diff --git a/GrpcInterface/Python/rips/tests/test_summary_cases.py b/GrpcInterface/Python/rips/tests/test_summary_cases.py index fdd5c349f9..2537db245f 100644 --- a/GrpcInterface/Python/rips/tests/test_summary_cases.py +++ b/GrpcInterface/Python/rips/tests/test_summary_cases.py @@ -109,6 +109,7 @@ def test_summary_no_unsmry(rips_instance, initialize_test): summary_case = rips_instance.project.import_summary_case(temp_path) assert summary_case is None + def test_summary_set_values(rips_instance, initialize_test): casePath = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC" summary_case = rips_instance.project.import_summary_case(casePath)