diff --git a/Dockerfile b/Dockerfile index f839d68a..fb4ad5d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,6 @@ RUN pip install --upgrade pip \ && apt-get install -y \ freetds-dev \ && rm -rf /var/lib/apt/lists/* -WORKDIR /workspace ARG version=3.8 COPY requirements/${version}.txt requirements.txt COPY setup.py README.rst ./ diff --git a/README.rst b/README.rst index 855d6624..09295f92 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,8 @@ testcontainers-python ===================== -.. image:: https://travis-ci.org/testcontainers/testcontainers-python.svg?branch=master - :target: https://travis-ci.org/testcontainers/testcontainers-python +.. image:: https://github.com/testcontainers/testcontainers-python/workflows/testcontainers-python/badge.svg + :target: https://github.com/testcontainers/testcontainers-python/actions/workflows/main.yml .. image:: https://img.shields.io/pypi/v/testcontainers.svg?style=flat-square :target: https://pypi.python.org/pypi/testcontainers .. image:: https://readthedocs.org/projects/testcontainers-python/badge/?version=latest diff --git a/testcontainers/neo4j.py b/testcontainers/neo4j.py index f2e6ce72..b1887de2 100644 --- a/testcontainers/neo4j.py +++ b/testcontainers/neo4j.py @@ -13,11 +13,8 @@ import os -import re -import time from neo4j import GraphDatabase -from testcontainers.core.exceptions import TimeoutException from testcontainers.core.generic import DbContainer from testcontainers.core.waiting_utils import wait_container_is_ready, wait_for_logs @@ -70,24 +67,19 @@ def get_connection_url(self): @wait_container_is_ready() def _connect(self): - deadline = time.time() + Neo4jContainer.NEO4J_STARTUP_TIMEOUT_SECONDS - regex = re.compile("Remote interface available at", re.MULTILINE).search - # First we wait for Neo4j to say it's listening - wait_for_logs(self, regex, Neo4jContainer.NEO4J_STARTUP_TIMEOUT_SECONDS) + wait_for_logs( + self, + "Remote interface available at", + Neo4jContainer.NEO4J_STARTUP_TIMEOUT_SECONDS, + ) # Then we actually check that the container really is listening - while time.time() < deadline: - with self.get_driver() as driver: - # Drivers may or may not be lazy - # force them to do a round trip to confirm neo4j is working - with driver.session() as session: - session.run("RETURN 1").single() - return - - raise TimeoutException( - "Neo4j did not start within %.3f seconds" % Neo4jContainer.NEO4J_STARTUP_TIMEOUT_SECONDS - ) + with self.get_driver() as driver: + # Drivers may or may not be lazy + # force them to do a round trip to confirm neo4j is working + with driver.session() as session: + session.run("RETURN 1").single() def get_driver(self, **kwargs): return GraphDatabase.driver( diff --git a/testcontainers/redis.py b/testcontainers/redis.py index a8007d59..3b1fc5c2 100644 --- a/testcontainers/redis.py +++ b/testcontainers/redis.py @@ -27,7 +27,7 @@ def __init__(self, image="redis:latest", port_to_expose=6379): def _connect(self): client = self.get_client() if not client.ping(): - raise Exception + raise redis.exceptions.ConnectionError("Could not connect to Redis") def get_client(self, **kwargs): """get redis client