From 16832e4f39bca4d1a99fa893631da1cb577ee512 Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Fri, 15 Mar 2019 11:14:19 +0100
Subject: [PATCH] [test] Fix docker network object handling

The network created during a test run was not properly deleted.
---
 beat/core/test/__init__.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/beat/core/test/__init__.py b/beat/core/test/__init__.py
index 2f67c749..9778eafa 100644
--- a/beat/core/test/__init__.py
+++ b/beat/core/test/__init__.py
@@ -57,6 +57,7 @@ DOCKER_NETWORK_TEST_ENABLED = (
     os.environ.get("DOCKER_NETWORK_TEST_ENABLED", False) == "True"
 )
 network_name = os.environ.get("DOCKER_TEST_NETWORK", "beat_core_test_network")
+global network
 network = None
 
 # Setup the logging system
@@ -90,6 +91,8 @@ def setup_package():
     if DOCKER_NETWORK_TEST_ENABLED:
         import docker
 
+        global network
+
         client = docker.from_env()
         try:
             network = client.networks.get(network_name)
@@ -112,5 +115,6 @@ def teardown_package():
     shutil.rmtree(prefix_folder)
 
     if DOCKER_NETWORK_TEST_ENABLED:
+        global network
         if network:
             network.remove()
-- 
GitLab