Skip to content

Commit 15e99ee

Browse files
add modifications
1 parent 7337266 commit 15e99ee

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

core/tests/test_docker_in_docker.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import time
55
import socket
6+
import sys
67
from pathlib import Path
78
from typing import Final, Any, Generator
89

@@ -19,6 +20,13 @@
1920
from testcontainers.core.utils import is_mac
2021
from testcontainers.core.waiting_utils import wait_for_logs
2122

23+
_DIND_PYTHON_VERSION = (3, 13)
24+
25+
26+
def _should_run_dind() -> bool:
27+
# todo refine macos check -> run in ci but not locally
28+
return not is_mac() and tuple([*sys.version_info][:2]) == _DIND_PYTHON_VERSION
29+
2230

2331
def _wait_for_dind_return_ip(client: DockerClient, dind: Container):
2432
# get ip address for DOCKER_HOST
@@ -38,7 +46,7 @@ def _wait_for_dind_return_ip(client: DockerClient, dind: Container):
3846
return docker_host_ip
3947

4048

41-
@pytest.mark.skipif(is_mac(), reason="Docker socket forwarding (socat) is unsupported on Docker Desktop for macOS")
49+
@pytest.mark.skipif(_should_run_dind(), reason="Docker socket forwarding (socat) is unsupported on Docker Desktop for macOS")
4250
def test_wait_for_logs_docker_in_docker():
4351
# real dind isn't possible (AFAIK) in CI
4452
# forwarding the socket to a container port is at least somewhat the same
@@ -68,7 +76,7 @@ def test_wait_for_logs_docker_in_docker():
6876

6977

7078
@pytest.mark.skipif(
71-
is_mac(), reason="Bridge networking and Docker socket forwarding are not supported on Docker Desktop for macOS"
79+
_should_run_dind(), reason="Bridge networking and Docker socket forwarding are not supported on Docker Desktop for macOS"
7280
)
7381
def test_dind_inherits_network():
7482
client = DockerClient()
@@ -152,7 +160,7 @@ def get_docker_info() -> dict[str, Any]:
152160
# see https://forums.docker.com/t/get-a-containers-full-id-from-inside-of-itself
153161
@pytest.mark.xfail(reason="Does not work in rootles docker i.e. github actions")
154162
@pytest.mark.inside_docker_check
155-
@pytest.mark.skipif(not os.environ.get(EXPECTED_NETWORK_VAR), reason="No expected network given")
163+
@pytest.mark.skipif(_should_run_dind() or not os.environ.get(EXPECTED_NETWORK_VAR), reason="No expected network given")
156164
def test_find_host_network_in_dood() -> None:
157165
"""
158166
Check that the correct host network is found for DooD
@@ -165,7 +173,7 @@ def test_find_host_network_in_dood() -> None:
165173

166174

167175
@pytest.mark.skipif(
168-
is_mac(), reason="Docker socket mounting and container networking do not work reliably on Docker Desktop for macOS"
176+
_should_run_dind(), reason="Docker socket mounting and container networking do not work reliably on Docker Desktop for macOS"
169177
)
170178
@pytest.mark.skipif(not Path(tcc.ryuk_docker_socket).exists(), reason="No docker socket available")
171179
def test_dood(python_testcontainer_image: str) -> None:
@@ -202,6 +210,9 @@ def test_dood(python_testcontainer_image: str) -> None:
202210
assert status["StatusCode"] == 0
203211

204212

213+
@pytest.mark.skipif(
214+
_should_run_dind(), reason="Docker socket mounting and container networking do not work reliably on Docker Desktop for macOS"
215+
)
205216
def test_dind(python_testcontainer_image: str, tmp_path: Path) -> None:
206217
"""
207218
Run selected tests in Docker in Docker

0 commit comments

Comments
 (0)