Skip to content

Commit ae8af9d

Browse files
alexanderankinmatthiasschaub
authored andcommitted
idea for configuring container reuse related to testcontainers#109
1 parent 1f50a62 commit ae8af9d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

core/testcontainers/core/config.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def read_tc_properties() -> dict[str, str]:
4040
return settings
4141

4242

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

4548

4649
@dataclass
@@ -75,8 +78,19 @@ def docker_auth_config(self, value: str):
7578
self._docker_auth_config = value
7679

7780
def tc_properties_get_tc_host(self) -> Union[str, None]:
81+
if "tc_properties_get_tc_host" in _WARNINGS:
82+
warning(_WARNINGS.pop("tc_properties_get_tc_host"))
7883
return self.tc_properties.get("tc.host")
7984

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

core/testcontainers/core/docker_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def find_container_by_hash(self, hash_: str) -> Container | None:
224224

225225

226226
def get_docker_host() -> Optional[str]:
227-
return c.tc_properties_get_tc_host() or os.getenv("DOCKER_HOST")
227+
return c.tc_properties_tc_host or os.getenv("DOCKER_HOST")
228228

229229

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

0 commit comments

Comments
 (0)