Skip to content

Commit 80976e5

Browse files
committed
check test results correctly in docker:dind
1 parent 4f28b03 commit 80976e5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tests/test_docker_compose.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22

33
from testcontainers.compose import DockerCompose
4+
from testcontainers.core.docker_client import DockerClient
45
from testcontainers.core.exceptions import NoSuchPortExposed
5-
from testcontainers.core.utils import inside_container
66

77

88
def test_can_spawn_service_via_compose():
@@ -29,5 +29,5 @@ def test_can_throw_exception_if_no_port_exposed():
2929

3030
def test_compose_wait_for_container_ready():
3131
with DockerCompose("tests") as compose:
32-
host = "host.docker.internal" if inside_container() else "localhost"
33-
compose.wait_for("http://%s:4444/wd/hub" % host)
32+
docker = DockerClient()
33+
compose.wait_for("http://%s:4444/wd/hub" % docker.host())

tests/test_new_docker_api.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ def test_docker_env_variables():
3131
db.with_bind_ports(3306, 32785)
3232
with db:
3333
url = db.get_connection_url()
34-
if inside_container():
35-
assert re.match(r'mysql\+pymysql://demo:test@(\d+\.){3}\d+:3306/custom_db', url)
36-
else:
37-
assert url == 'mysql+pymysql://demo:test@localhost:32785/custom_db'
34+
pattern = r'mysql\+pymysql:\/\/demo:test@[\w,.]+:(3306|32785)\/custom_db'
35+
assert re.match(pattern, url)
3836

3937

4038
def test_docker_kargs():

0 commit comments

Comments
 (0)