Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix improving error handling when Docker daemon is not running #7

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Check code style
if: matrix.python-version != '3.6'
run: |
poe check-style
poe lint

- name: Run tests
run: |
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
================
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,17 @@ line-length = 120
# ===================

[tool.poe.tasks]

check = [
"lint",
"test",
]

format = [
{cmd="black ."},
{cmd="isort pytest_mqtt testing"},
]
check-style = [
lint = [
{cmd="ruff ."},
{cmd="black --check ."},
{cmd="isort --check pytest_mqtt testing"},
Expand Down
7 changes: 5 additions & 2 deletions pytest_mqtt/mosquitto.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@
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?")

Check warning on line 62 in pytest_mqtt/mosquitto.py

View check run for this annotation

Codecov / codecov/patch

pytest_mqtt/mosquitto.py#L61-L62

Added lines #L61 - L62 were not covered by tests
try:
docker_client.ping()
except Exception:
Expand Down