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
This commit is contained in:
Magne Sjaastad 2022-03-25 18:54:07 +01:00
parent ef842e7f27
commit 751bf22a6b
2 changed files with 4 additions and 0 deletions

View File

@ -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:

View File

@ -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)