Skip to content

Commit f5a16cb

Browse files
committed
Rename port_to_expose to port for Redis and Elasticsearch.
1 parent 7f08e44 commit f5a16cb

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

elasticsearch/testcontainers/elasticsearch/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ class ElasticSearchContainer(DockerContainer):
7373
'8.3.3'
7474
"""
7575

76-
def __init__(self, image="elasticsearch", port_to_expose=9200, **kwargs) -> None:
76+
def __init__(self, image: str = "elasticsearch", port: int = 9200, port_to_expose: None = None,
77+
**kwargs) -> None:
78+
if port_to_expose:
79+
raise ValueError("use `port` instead of `port_to_expose`")
7780
super(ElasticSearchContainer, self).__init__(image, **kwargs)
78-
self.port_to_expose = port_to_expose
81+
self.port_to_expose = port
7982
self.with_exposed_ports(self.port_to_expose)
8083
self.with_env('transport.host', '127.0.0.1')
8184
self.with_env('http.host', '0.0.0.0')

redis/testcontainers/redis/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@
1414
import redis
1515
from testcontainers.core.container import DockerContainer
1616
from testcontainers.core.waiting_utils import wait_container_is_ready
17+
from typing import Optional
1718

1819

1920
class RedisContainer(DockerContainer):
2021
"""
21-
Redis container.
22+
Redis container.
2223
23-
Example:
24+
Example:
2425
25-
.. doctest::
26+
.. doctest::
2627
27-
>>> from testcontainers.redis import RedisContainer
28+
>>> from testcontainers.redis import RedisContainer
2829
29-
>>> with RedisContainer() as redis_container:
30-
... redis_client = redis_container.get_client()
31-
"""
32-
def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **kwargs) -> None:
30+
>>> with RedisContainer() as redis_container:
31+
... redis_client = redis_container.get_client()
32+
"""
33+
def __init__(self, image: str = "redis:latest", port: int = 6379,
34+
password: Optional[str] = None, port_to_expose: None = None, **kwargs) -> None:
35+
if port_to_expose:
36+
raise ValueError("use `port` instead of `port_to_expose`")
3337
super(RedisContainer, self).__init__(image, **kwargs)
34-
self.port_to_expose = port_to_expose
38+
self.port_to_expose = port
3539
self.password = password
3640
self.with_exposed_ports(self.port_to_expose)
3741
if self.password:

0 commit comments

Comments
 (0)