Merge changes from topics 'YARDSTICK-1218', 'YARDSTICK-1216', 'YARDSTICK-1215', ...
[yardstick.git] / yardstick / tests / unit / benchmark / core / test_task.py
index 9e8e4e9..7468368 100644 (file)
@@ -17,6 +17,7 @@ import six
 import unittest
 import uuid
 
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts import dummy
 from yardstick.benchmark.core import task
 from yardstick.common import constants as consts
@@ -357,6 +358,12 @@ key2:
                 }
             }
 
+    @staticmethod
+    def _remove_contexts():
+        for context in base.Context.list:
+            context._delete_context()
+        base.Context.list = []
+
     def test__change_node_names(self):
 
         ctx_attrs = {
@@ -371,6 +378,7 @@ key2:
             }
 
         my_context = dummy.DummyContext()
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
 
         expected_scenario = {
@@ -413,6 +421,7 @@ key2:
             }
 
         my_context = dummy.DummyContext()
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
 
         scenario = copy.deepcopy(self.scenario)
@@ -428,6 +437,7 @@ key2:
         }
 
         my_context = dummy.DummyContext()
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
         scenario = copy.deepcopy(self.scenario)
         scenario['options'] = None
@@ -442,6 +452,7 @@ key2:
         }
 
         my_context = dummy.DummyContext()
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
         scenario = copy.deepcopy(self.scenario)
         scenario['options']['server_name'] = None