From fb43ffffa9b5806ffa3922ed10437a58934e17ee Mon Sep 17 00:00:00 2001 From: David Ankin Date: Mon, 17 Feb 2025 08:24:39 -0500 Subject: [PATCH 1/3] fix: use connection mode override function in config --- core/testcontainers/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/testcontainers/core/config.py b/core/testcontainers/core/config.py index cee09aa7..9c3889e0 100644 --- a/core/testcontainers/core/config.py +++ b/core/testcontainers/core/config.py @@ -106,7 +106,7 @@ class TestcontainersConfiguration: tc_properties: dict[str, str] = field(default_factory=read_tc_properties) _docker_auth_config: Optional[str] = field(default_factory=lambda: environ.get("DOCKER_AUTH_CONFIG")) tc_host_override: Optional[str] = TC_HOST_OVERRIDE - connection_mode_override: Optional[ConnectionMode] = None + connection_mode_override: Optional[ConnectionMode] = field(default_factory=get_user_overwritten_connection_mode) """ https://github.com/testcontainers/testcontainers-go/blob/dd76d1e39c654433a3d80429690d07abcec04424/docker.go#L644 From a0aa9c3f8d897138327c23ff88340ead324431ed Mon Sep 17 00:00:00 2001 From: David Ankin Date: Mon, 17 Feb 2025 08:26:49 -0500 Subject: [PATCH 2/3] add test --- core/tests/test_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/tests/test_config.py b/core/tests/test_config.py index 0ddd8333..36f82362 100644 --- a/core/tests/test_config.py +++ b/core/tests/test_config.py @@ -3,7 +3,7 @@ from testcontainers.core.config import ( TestcontainersConfiguration as TCC, TC_FILE, - get_user_overwritten_connection_mode, + TestcontainersConfiguration, get_user_overwritten_connection_mode, ConnectionMode, get_docker_socket, ) @@ -81,6 +81,7 @@ def test_invalid_connection_mode(monkeypatch: pytest.MonkeyPatch) -> None: def test_valid_connection_mode(monkeypatch: pytest.MonkeyPatch, mode: str, use_mapped: bool) -> None: monkeypatch.setenv("TESTCONTAINERS_CONNECTION_MODE", mode) assert get_user_overwritten_connection_mode().use_mapped_port is use_mapped + assert TestcontainersConfiguration().connection_mode_override.use_mapped_port is use_mapped def test_no_connection_mode_given(monkeypatch: pytest.MonkeyPatch) -> None: From 62253f30bfd3a76f5c9a799cffdcdfa40e086d02 Mon Sep 17 00:00:00 2001 From: David Ankin Date: Mon, 17 Feb 2025 08:28:12 -0500 Subject: [PATCH 3/3] ruff vs IDEA - fight, fight, fight --- core/tests/test_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/tests/test_config.py b/core/tests/test_config.py index 36f82362..845ca7ac 100644 --- a/core/tests/test_config.py +++ b/core/tests/test_config.py @@ -3,7 +3,8 @@ from testcontainers.core.config import ( TestcontainersConfiguration as TCC, TC_FILE, - TestcontainersConfiguration, get_user_overwritten_connection_mode, + TestcontainersConfiguration, + get_user_overwritten_connection_mode, ConnectionMode, get_docker_socket, )