Skip to content

Commit

Permalink
fix(tests): replace dind-test direct docker usage with sdk (#750)
Browse files Browse the repository at this point in the history
fix: #749

Replace using `subprocess.run` in the **dind** test with SDK to avoid
the direct call to docker that enforces the developer to run _sudoless_
docker.
  • Loading branch information
Tranquility2 authored Dec 15, 2024
1 parent 8d77bd3 commit ace2a7d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest
from typing import Callable
import subprocess
from testcontainers.core.container import DockerClient
import sys

Expand All @@ -24,10 +23,12 @@ def python_testcontainer_image() -> str:
"""Build an image with test containers python for DinD and DooD tests"""
py_version = ".".join(map(str, sys.version_info[:2]))
image_name = f"testcontainers-python:{py_version}"
subprocess.run(
[*("docker", "build"), *("--build-arg", f"PYTHON_VERSION={py_version}"), *("-t", image_name), "."],
cwd=PROJECT_DIR,
check=True,
client = DockerClient()
client.build(
path=str(PROJECT_DIR),
tag=image_name,
rm=False,
buildargs={"PYTHON_VERSION": py_version},
)
return image_name

Expand Down

0 comments on commit ace2a7d

Please sign in to comment.