Skip to content

Commit 980ef83

Browse files
committed
docker-compose wait_for reade method added
1 parent 1afc2da commit 980ef83

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

testcontainers/compose.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import subprocess
22

33
import blindspin
4+
import requests
45

6+
from testcontainers import wait_container_is_ready
57
from testcontainers.core.exceptions import NoSuchPortExposed
68

79

@@ -36,3 +38,8 @@ def _get_service_info(self, service, port):
3638
if len(result) == 1:
3739
raise NoSuchPortExposed("Port {} was not exposed for service {}".format(port, service))
3840
return result
41+
42+
@wait_container_is_ready()
43+
def wait_for(self, url):
44+
requests.get(url)
45+
return self

tests/test_docker_compose.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
import pytest
4+
from selenium import webdriver
45

56
from testcontainers.compose import DockerCompose
67
from testcontainers.core.exceptions import NoSuchPortExposed
@@ -27,3 +28,9 @@ def test_can_throw_exception_if_no_port_exposed():
2728
compose.get_service_host("hub", 5555)
2829

2930
compose.stop()
31+
32+
33+
def test_compose_wait_for_container_ready():
34+
compose = DockerCompose(os.path.dirname(__file__))
35+
with compose:
36+
compose.wait_for("http://localhost:4444/wd/hub")

0 commit comments

Comments
 (0)