diff --git a/podman_compose.py b/podman_compose.py index 9e3efe0..d9deced 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -1748,7 +1748,7 @@ class PodmanCompose: help="Specify a profile to enable", metavar="profile", action="append", - default=[] + default=[], ) parser.add_argument( "-p", diff --git a/tests/test_podman_compose_config.py b/tests/test_podman_compose_config.py index 4ece5ab..cbe68a3 100644 --- a/tests/test_podman_compose_config.py +++ b/tests/test_podman_compose_config.py @@ -10,7 +10,7 @@ from test_podman_compose import capture @pytest.fixture def profile_compose_file(test_path): - """"Returns the path to the `profile` compose file used for this test module""" + """ "Returns the path to the `profile` compose file used for this test module""" return os.path.join(test_path, "profile", "docker-compose.yml") @@ -21,13 +21,7 @@ def test_config_no_profiles(podman_compose_path, profile_compose_file): :param podman_compose_path: The fixture used to specify the path to the podman compose file. :param profile_compose_file: The fixtued used to specify the path to the "profile" compose used in the test. """ - config_cmd = [ - "python3", - podman_compose_path, - "-f", - profile_compose_file, - "config" - ] + config_cmd = ["python3", podman_compose_path, "-f", profile_compose_file, "config"] out, err, return_code = capture(config_cmd) assert return_code == 0 @@ -38,16 +32,26 @@ def test_config_no_profiles(podman_compose_path, profile_compose_file): assert "service-2" not in string_output -@pytest.mark.parametrize("profiles, expected_services", - [ - (["--profile", "profile-1", "config"], - {"default-service": True, "service-1": True, "service-2": False}), - (["--profile", "profile-2", "config"], - {"default-service": True, "service-1": False, "service-2": True}), - (["--profile", "profile-1", "--profile", "profile-2", "config"], - {"default-service": True, "service-1": True, "service-2": True}) - ]) -def test_config_profiles(podman_compose_path, profile_compose_file, profiles, expected_services): +@pytest.mark.parametrize( + "profiles, expected_services", + [ + ( + ["--profile", "profile-1", "config"], + {"default-service": True, "service-1": True, "service-2": False}, + ), + ( + ["--profile", "profile-2", "config"], + {"default-service": True, "service-1": False, "service-2": True}, + ), + ( + ["--profile", "profile-1", "--profile", "profile-2", "config"], + {"default-service": True, "service-1": True, "service-2": True}, + ), + ], +) +def test_config_profiles( + podman_compose_path, profile_compose_file, profiles, expected_services +): """ Tests podman-compose :param podman_compose_path: The fixture used to specify the path to the podman compose file. @@ -56,12 +60,7 @@ def test_config_profiles(podman_compose_path, profile_compose_file, profiles, ex :param expected_services: Dictionary used to model the expected "enabled" services in the profile. Key = service name, Value = True if the service is enabled, otherwise False. """ - config_cmd = [ - "python3", - podman_compose_path, - "-f", - profile_compose_file - ] + config_cmd = ["python3", podman_compose_path, "-f", profile_compose_file] config_cmd.extend(profiles) out, err, return_code = capture(config_cmd) diff --git a/tests/test_podman_compose_up_down.py b/tests/test_podman_compose_up_down.py index 33c1c34..af511c4 100644 --- a/tests/test_podman_compose_up_down.py +++ b/tests/test_podman_compose_up_down.py @@ -10,7 +10,7 @@ from test_podman_compose import capture @pytest.fixture def profile_compose_file(test_path): - """"Returns the path to the `profile` compose file used for this test module""" + """ "Returns the path to the `profile` compose file used for this test module""" return os.path.join(test_path, "profile", "docker-compose.yml") @@ -34,20 +34,28 @@ def teardown(podman_compose_path, profile_compose_file): "profile-2", "-f", profile_compose_file, - "down" + "down", ] capture(down_cmd) -@pytest.mark.parametrize("profiles, expected_services", - [ - (["--profile", "profile-1", "up", "-d"], - {"default-service": True, "service-1": True, "service-2": False}), - (["--profile", "profile-2", "up", "-d"], - {"default-service": True, "service-1": False, "service-2": True}), - (["--profile", "profile-1", "--profile", "profile-2", "up", "-d"], - {"default-service": True, "service-1": True, "service-2": True}) - ]) +@pytest.mark.parametrize( + "profiles, expected_services", + [ + ( + ["--profile", "profile-1", "up", "-d"], + {"default-service": True, "service-1": True, "service-2": False}, + ), + ( + ["--profile", "profile-2", "up", "-d"], + {"default-service": True, "service-1": False, "service-2": True}, + ), + ( + ["--profile", "profile-1", "--profile", "profile-2", "up", "-d"], + {"default-service": True, "service-1": True, "service-2": True}, + ), + ], +) def test_up(podman_compose_path, profile_compose_file, profiles, expected_services): up_cmd = [ "python3",