Skip to content

Commit f172603

Browse files
author
sepi
committed
bd version parameter added to constructor
1 parent c974256 commit f172603

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

testcontainers/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
}
3939

4040
postgres_container = {
41-
"image": "postgres:latest",
4241
"env": {
4342
"POSTGRES_USER": postgres_db["user"],
4443
"POSTGRES_PASSWORD": postgres_db["passwd"],

testcontainers/mysql.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77

88
class MySqlDockerContainer(DockerContainer):
9-
def __init__(self, image='mysql:latest'):
10-
super(DockerContainer, self).__init__()
11-
self.image = image
9+
def __init__(self, version='latest', image='mysql'):
10+
super(self.__class__, self).__init__()
11+
self.image = "{}:{}".format(image, version)
1212

1313
def start(self):
1414
"""

testcontainers/postgres.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def start(self):
1212

1313
@wait_container_is_ready()
1414
def connection(self):
15-
return psycopg2.connect(**config.postgres_db)
15+
return psycopg2.connect(self.image, **config.postgres_db)
1616

17-
def __init__(self, image="postgres:latest"):
17+
def __init__(self, version='latest', image="postgres"):
1818
super(DockerContainer, self).__init__()
19-
config.postgres_container["image"] = image
19+
self.image = "{}:{}".format(image, version)

tests/test_docker_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_docker_run_selenium():
1515

1616

1717
def test_docker_run_mysql():
18-
with MySqlDockerContainer() as mysql:
18+
with MySqlDockerContainer('5.5') as mysql:
1919
conn = mysql.connection()
2020
cur = conn.cursor()
2121

0 commit comments

Comments
 (0)