diff --git a/pytest_container/pod.py b/pytest_container/pod.py index 3ec627d..57b9b68 100644 --- a/pytest_container/pod.py +++ b/pytest_container/pod.py @@ -142,8 +142,10 @@ def launch_pod(self) -> None: """ runtime = get_selected_runtime() - create_cmd = [runtime.runner_binary, "pod", "create"] + ( - ["--name", self.pod_name] if self.pod_name else [] + create_cmd = ( + [runtime.runner_binary, "pod", "create"] + + (["--name", self.pod_name] if self.pod_name else []) + + self.extra_pod_create_args ) if self.pod.forwarded_ports: diff --git a/tests/test_pod.py b/tests/test_pod.py index 45225b9..37df9c5 100644 --- a/tests/test_pod.py +++ b/tests/test_pod.py @@ -41,16 +41,26 @@ def test_pod_launcher( - container_runtime: OciRuntimeBase, pytestconfig: pytest.Config + tmp_path: Path, + container_runtime: OciRuntimeBase, + pytestconfig: pytest.Config, ) -> None: if container_runtime != PodmanRuntime(): pytest.skip("pods only work with podman") - with PodLauncher(pod=TEST_POD, rootdir=pytestconfig.rootpath) as launcher: + pidfile_path = str(tmp_path / "pidfile") + with PodLauncher( + pod=TEST_POD, + rootdir=pytestconfig.rootpath, + extra_pod_create_args=["--pod-id-file", pidfile_path], + ) as launcher: launcher.launch_pod() pod_data = launcher.pod_data assert pod_data.pod_id and pod_data.infra_container_id + with open(pidfile_path, encoding="utf-8") as pyproject: + assert pod_data.pod_id == pyproject.read() + assert ( len(pod_data.forwarded_ports) == 2 and pod_data.forwarded_ports[0].container_port == 80