Skip to content

Commit b4ccb97

Browse files
committed
pass kwargs to parent constructor
1 parent b0ffcc6 commit b4ccb97

File tree

13 files changed

+26
-24
lines changed

13 files changed

+26
-24
lines changed

testcontainers/elasticsearch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class ElasticSearchContainer(DockerContainer):
2727
with ElasticSearchContainer() as es:
2828
connection_url = es.get_url()
2929
"""
30-
def __init__(self, image="elasticsearch", port_to_expose=9200):
31-
super(ElasticSearchContainer, self).__init__(image)
30+
def __init__(self, image="elasticsearch", port_to_expose=9200, **kwargs):
31+
super(ElasticSearchContainer, self).__init__(image, **kwargs)
3232
self.port_to_expose = port_to_expose
3333
self.with_exposed_ports(self.port_to_expose)
3434
self.with_env('transport.host', '127.0.0.1')

testcontainers/google/pubsub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def test_docker_run_pubsub():
3434
topic = publisher.create_topic(topic_path)
3535
"""
3636
def __init__(self, image="google/cloud-sdk:latest",
37-
project="test-project", port=8432):
38-
super(PubSubContainer, self).__init__(image=image)
37+
project="test-project", port=8432, **kwargs):
38+
super(PubSubContainer, self).__init__(image=image, **kwargs)
3939
self.project = project
4040
self.port = port
4141
self.with_exposed_ports(self.port)

testcontainers/kafka.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class KafkaContainer(DockerContainer):
1414
KAFKA_PORT = 9093
1515
TC_START_SCRIPT = '/tc-start.sh'
1616

17-
def __init__(self, image="confluentinc/cp-kafka:5.4.3", port_to_expose=KAFKA_PORT):
18-
super(KafkaContainer, self).__init__(image)
17+
def __init__(self, image="confluentinc/cp-kafka:5.4.3", port_to_expose=KAFKA_PORT, **kwargs):
18+
super(KafkaContainer, self).__init__(image, **kwargs)
1919
self.port_to_expose = port_to_expose
2020
self.with_exposed_ports(self.port_to_expose)
2121
listeners = 'PLAINTEXT://0.0.0.0:{},BROKER://0.0.0.0:9092'.format(port_to_expose)

testcontainers/localstack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class LocalStackContainer(DockerContainer):
3232
EDGE_PORT = 4566
3333
IMAGE = 'localstack/localstack:0.11.4'
3434

35-
def __init__(self, image=IMAGE):
36-
super(LocalStackContainer, self).__init__(image)
35+
def __init__(self, image=IMAGE, **kwargs):
36+
super(LocalStackContainer, self).__init__(image, **kwargs)
3737
self.with_exposed_ports(LocalStackContainer.EDGE_PORT)
3838

3939
def with_services(self, *services):

testcontainers/mongodb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class MongoDbContainer(DbContainer):
5050
MONGO_INITDB_ROOT_PASSWORD = os.environ.get("MONGO_INITDB_ROOT_PASSWORD", "test")
5151
MONGO_DB = os.environ.get("MONGO_DB", "test")
5252

53-
def __init__(self, image="mongo:latest"):
54-
super(MongoDbContainer, self).__init__(image=image)
53+
def __init__(self, image="mongo:latest", **kwargs):
54+
super(MongoDbContainer, self).__init__(image=image, **kwargs)
5555
self.command = "mongo"
5656
self.port_to_expose = 27017
5757
self.with_exposed_ports(self.port_to_expose)

testcontainers/mssql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class SqlServerContainer(DbContainer):
2121
linux-mac/installing-the-microsoft-odbc-driver-for-sql-server>`_.
2222
"""
2323
def __init__(self, image="mcr.microsoft.com/mssql/server:2019-latest", user="SA", password=None,
24-
port=1433, dbname="tempdb", dialect='mssql+pymssql'):
25-
super(SqlServerContainer, self).__init__(image)
24+
port=1433, dbname="tempdb", dialect='mssql+pymssql', **kwargs):
25+
super(SqlServerContainer, self).__init__(image, **kwargs)
2626

2727
self.SQLSERVER_PASSWORD = password or environ.get("SQLSERVER_PASSWORD", "1Secure*Password1")
2828
self.port_to_expose = port

testcontainers/neo4j.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Neo4jContainer(DbContainer):
4747
NEO4J_USER = "neo4j"
4848

4949
def __init__(self, image="neo4j:latest", **kwargs):
50-
super(Neo4jContainer, self).__init__(image)
50+
super(Neo4jContainer, self).__init__(image, **kwargs)
5151
self.bolt_port = Neo4jContainer.DEFAULT_BOLT_PORT
5252
self.with_exposed_ports(self.bolt_port)
5353
self._driver = None

testcontainers/nginx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class NginxContainer(DockerContainer):
1818
@deprecated(details="Use `DockerContainer` with 'nginx:latest' image and expose port 80.")
19-
def __init__(self, image="nginx:latest", port_to_expose=80):
20-
super(NginxContainer, self).__init__(image)
19+
def __init__(self, image="nginx:latest", port_to_expose=80, **kwargs):
20+
super(NginxContainer, self).__init__(image, **kwargs)
2121
self.port_to_expose = port_to_expose
2222
self.with_exposed_ports(self.port_to_expose)

testcontainers/oracle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class OracleDbContainer(DbContainer):
1313
e = sqlalchemy.create_engine(oracle.get_connection_url())
1414
result = e.execute("select 1 from dual")
1515
"""
16-
def __init__(self, image="wnameless/oracle-xe-11g-r2:latest"):
17-
super(OracleDbContainer, self).__init__(image=image)
16+
def __init__(self, image="wnameless/oracle-xe-11g-r2:latest", **kwargs):
17+
super(OracleDbContainer, self).__init__(image=image, **kwargs)
1818
self.container_port = 1521
1919
self.with_exposed_ports(self.container_port)
2020
self.with_env("ORACLE_ALLOW_REMOTE", "true")

testcontainers/postgres.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def __init__(self,
3737
port=5432, user=None,
3838
password=None,
3939
dbname=None,
40-
driver="psycopg2"):
41-
super(PostgresContainer, self).__init__(image=image)
40+
driver="psycopg2",
41+
**kwargs):
42+
super(PostgresContainer, self).__init__(image=image, **kwargs)
4243
self.POSTGRES_USER = user or self.POSTGRES_USER
4344
self.POSTGRES_PASSWORD = password or self.POSTGRES_PASSWORD
4445
self.POSTGRES_DB = dbname or self.POSTGRES_DB

0 commit comments

Comments
 (0)