Skip to content

Commit ab2a1ab

Browse files
fix: use connection mode override function in config (#775)
fix #774
1 parent f7c29cb commit ab2a1ab

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Diff for: core/testcontainers/core/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class TestcontainersConfiguration:
106106
tc_properties: dict[str, str] = field(default_factory=read_tc_properties)
107107
_docker_auth_config: Optional[str] = field(default_factory=lambda: environ.get("DOCKER_AUTH_CONFIG"))
108108
tc_host_override: Optional[str] = TC_HOST_OVERRIDE
109-
connection_mode_override: Optional[ConnectionMode] = None
109+
connection_mode_override: Optional[ConnectionMode] = field(default_factory=get_user_overwritten_connection_mode)
110110

111111
"""
112112
https://github.com/testcontainers/testcontainers-go/blob/dd76d1e39c654433a3d80429690d07abcec04424/docker.go#L644

Diff for: core/tests/test_config.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from testcontainers.core.config import (
44
TestcontainersConfiguration as TCC,
55
TC_FILE,
6+
TestcontainersConfiguration,
67
get_user_overwritten_connection_mode,
78
ConnectionMode,
89
get_docker_socket,
@@ -81,6 +82,7 @@ def test_invalid_connection_mode(monkeypatch: pytest.MonkeyPatch) -> None:
8182
def test_valid_connection_mode(monkeypatch: pytest.MonkeyPatch, mode: str, use_mapped: bool) -> None:
8283
monkeypatch.setenv("TESTCONTAINERS_CONNECTION_MODE", mode)
8384
assert get_user_overwritten_connection_mode().use_mapped_port is use_mapped
85+
assert TestcontainersConfiguration().connection_mode_override.use_mapped_port is use_mapped
8486

8587

8688
def test_no_connection_mode_given(monkeypatch: pytest.MonkeyPatch) -> None:

0 commit comments

Comments
 (0)