Skip to content

Commit 2669c27

Browse files
idea for configuring container reuse related to #109
1 parent 4766e48 commit 2669c27

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

core/testcontainers/core/config.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def read_tc_properties() -> dict[str, str]:
3939
return settings
4040

4141

42-
_WARNINGS = {"DOCKER_AUTH_CONFIG": "DOCKER_AUTH_CONFIG is experimental, see testcontainers/testcontainers-python#566"}
42+
_WARNINGS = {
43+
"DOCKER_AUTH_CONFIG": "DOCKER_AUTH_CONFIG is experimental, see testcontainers/testcontainers-python#566",
44+
"tc_properties_get_tc_host": "this method has moved to property 'tc_properties_tc_host'",
45+
}
4346

4447

4548
@dataclass
@@ -73,8 +76,19 @@ def docker_auth_config(self, value: str):
7376
self._docker_auth_config = value
7477

7578
def tc_properties_get_tc_host(self) -> Union[str, None]:
79+
if "tc_properties_get_tc_host" in _WARNINGS:
80+
warning(_WARNINGS.pop("tc_properties_get_tc_host"))
7681
return self.tc_properties.get("tc.host")
7782

83+
@property
84+
def tc_properties_tc_host(self) -> Union[str, None]:
85+
return self.tc_properties.get("tc.host")
86+
87+
@property
88+
def tc_properties_testcontainers_reuse_enable(self) -> Union[bool, None]:
89+
enabled = self.tc_properties.get("testcontainers.reuse.enable")
90+
return enabled == "true" if enabled else None
91+
7892
@property
7993
def timeout(self):
8094
return self.max_tries * self.sleep_time

core/testcontainers/core/docker_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def client_networks_create(self, name: str, param: dict):
217217

218218

219219
def get_docker_host() -> Optional[str]:
220-
return c.tc_properties_get_tc_host() or os.getenv("DOCKER_HOST")
220+
return c.tc_properties_tc_host or os.getenv("DOCKER_HOST")
221221

222222

223223
def get_docker_auth_config() -> Optional[str]:

0 commit comments

Comments
 (0)