Skip to content

fix: use connection mode override function in config #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/testcontainers/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions core/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from testcontainers.core.config import (
TestcontainersConfiguration as TCC,
TC_FILE,
TestcontainersConfiguration,
get_user_overwritten_connection_mode,
ConnectionMode,
get_docker_socket,
Expand Down Expand Up @@ -81,6 +82,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:
Expand Down