From d1509468c3ba21f8ee4c39c6f84387e5a43dc750 Mon Sep 17 00:00:00 2001 From: Sergei Biriukov Date: Sun, 30 Apr 2023 14:56:04 +1000 Subject: [PATCH] allow empty list to be a command/entrypoint Signed-off-by: Sergei Biriukov --- podman_compose.py | 2 -- pytests/test_is_list_of_str.py | 2 +- pytests/test_rec_merge_one_cmd_ent.py | 7 ++++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/podman_compose.py b/podman_compose.py index 97fb60e..017acbd 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -63,8 +63,6 @@ def is_list(list_object): def is_list_of_str(list_of_str_object): if is_list(list_of_str_object): - if len(list_of_str_object) == 0: - return False for element in list_of_str_object: if not is_str(element): return False diff --git a/pytests/test_is_list_of_str.py b/pytests/test_is_list_of_str.py index e5b8d7c..5e5766a 100644 --- a/pytests/test_is_list_of_str.py +++ b/pytests/test_is_list_of_str.py @@ -2,9 +2,9 @@ from podman_compose import is_list_of_str def test_is_list_of_str(): + assert is_list_of_str([]) assert is_list_of_str(["foo", "bar"]) assert not is_list_of_str(["foo", 1]) assert not is_list_of_str("foo") - assert not is_list_of_str([]) assert not is_list_of_str(1) assert not is_list_of_str(None) diff --git a/pytests/test_rec_merge_one_cmd_ent.py b/pytests/test_rec_merge_one_cmd_ent.py index 0ef3717..722606d 100644 --- a/pytests/test_rec_merge_one_cmd_ent.py +++ b/pytests/test_rec_merge_one_cmd_ent.py @@ -6,6 +6,10 @@ from podman_compose import rec_merge_one test_keys = ["command", "entrypoint"] test_cases = [ + ({}, {"$$$": []}, {"$$$": []}), + ({"$$$": []}, {}, {"$$$": []}), + ({"$$$": []}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}), + ({"$$$": "sh-2"}, {"$$$": []}, {"$$$": []}), ({}, {"$$$": "sh"}, {"$$$": ["sh"]}), ({"$$$": "sh"}, {}, {"$$$": ["sh"]}), ({"$$$": "sh-1"}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}), @@ -30,9 +34,6 @@ test_cases_with_exceptions = [ ({"$$$": {}}, {}, ValueError), ({}, {"$$$": {}}, ValueError), ({"$$$": {}}, {"$$$": {}}, ValueError), - ({"$$$": []}, {}, ValueError), - ({}, {"$$$": []}, ValueError), - ({"$$$": []}, {"$$$": []}, ValueError), ]