Skip to content

Commit 59ab38d

Browse files
cofinprovinzkraut
authored andcommitted
feat: adds support for podman
1 parent b6a6bde commit 59ab38d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pytest_databases/_service.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,18 @@ def get_docker_host() -> str:
3131
capture_output=True,
3232
check=True,
3333
)
34-
contexts = (json.loads(line) for line in result.stdout.splitlines())
34+
docker_ls = result.stdout.splitlines()
35+
# if this is empty, we are not in a dockerized environment; It's probably a podman environment on linux
36+
if not docker_ls or (len(docker_ls) == 1 and docker_ls[0] == "[]"):
37+
uid_result = subprocess.run(
38+
["id", "-u"], # noqa: S607
39+
text=True,
40+
capture_output=True,
41+
check=True,
42+
)
43+
uid = uid_result.stdout.strip()
44+
return f"unix:///run/user/{uid}/podman/podman.sock"
45+
contexts = (json.loads(line) for line in docker_ls)
3546
return next(context["DockerEndpoint"] for context in contexts if context["Current"] is True)
3647

3748

0 commit comments

Comments
 (0)