From 4866af878204cd1560c47b0239ed02e9a32142fb Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sun, 30 Jul 2023 16:12:57 +0200 Subject: [PATCH] Fix improving error handling when Docker daemon is not running --- CHANGES.rst | 2 ++ pytest_mqtt/mosquitto.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1515d57..6d23c2a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ pytest-mqtt changelog in progress =========== +- Fix improving error handling when Docker daemon is not running. + 2023-07-28 0.3.0 ================ diff --git a/pytest_mqtt/mosquitto.py b/pytest_mqtt/mosquitto.py index 9349df9..6726924 100644 --- a/pytest_mqtt/mosquitto.py +++ b/pytest_mqtt/mosquitto.py @@ -55,8 +55,11 @@ def pull_image(self): docker_client.images.pull(image_name) def run(self): - docker_client = docker.from_env(version=self.docker_version) - docker_url = docker_client.api.base_url + try: + docker_client = docker.from_env(version=self.docker_version) + docker_url = docker_client.api.base_url + except Exception: + raise ConnectionError("Cannot connect to the Docker daemon. Is the docker daemon running?") try: docker_client.ping() except Exception: