From 25273592b97edfdb6bafcb374f8db0fd520af732 Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 13 Jun 2018 16:28:49 +0200 Subject: [PATCH] don't cleanup services if they aren't available --- tests/conftest.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 99aef951..5282ab53 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,7 @@ from unittest import mock from docker import from_env as docker_from_env +from docker.errors import APIError import pytest from jupyterhub.tests.mocking import MockHub @@ -40,7 +41,12 @@ def docker(): if c.name.startswith("dockerspawner-test"): c.stop() c.remove() - - for c in d.services.list(): - if c.name.startswith("dockerspawner-test"): - c.remove() + try: + services = d.services.list() + except APIError: + # e.g. services not available + return + else: + for s in services: + if s.name.startswith("dockerspawner-test"): + s.remove()