17301: Add more logging handler teardown
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 25 Apr 2022 17:11:23 +0000 (13:11 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 25 Apr 2022 17:11:23 +0000 (13:11 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

sdk/cwl/tests/test_container.py
sdk/cwl/tests/test_make_output.py
sdk/cwl/tests/test_pathmapper.py

index 4d87d27e6e564147d4862b3445a7667fe21593a4..975fcdf8a3a25934729201b4e5ec987330311761 100644 (file)
@@ -63,6 +63,13 @@ class TestContainer(unittest.TestCase):
         cwltool.process._names = set()
         arv_docker_clear_cache()
 
+    def tearDown(self):
+        root_logger = logging.getLogger('')
+
+        # Remove existing RuntimeStatusLoggingHandlers if they exist
+        handlers = [h for h in root_logger.handlers if not isinstance(h, arvados_cwl.executor.RuntimeStatusLoggingHandler)]
+        root_logger.handlers = handlers
+
     def helper(self, runner, enable_reuse=True):
         document_loader, avsc_names, schema_metadata, metaschema_loader = cwltool.process.get_schema(INTERNAL_VERSION)
 
index 127b3f372bed10615ce6fa701740201e649b1b6b..fe269592cb50619477e8effdf60ba4a42d4860aa 100644 (file)
@@ -23,6 +23,13 @@ class TestMakeOutput(unittest.TestCase):
         self.api = mock.MagicMock()
         self.api._rootDesc = get_rootDesc()
 
+    def tearDown(self):
+        root_logger = logging.getLogger('')
+
+        # Remove existing RuntimeStatusLoggingHandlers if they exist
+        handlers = [h for h in root_logger.handlers if not isinstance(h, arvados_cwl.executor.RuntimeStatusLoggingHandler)]
+        root_logger.handlers = handlers
+
     @mock.patch("arvados.collection.Collection")
     @mock.patch("arvados.collection.CollectionReader")
     def test_make_output_collection(self, reader, col):
@@ -171,4 +178,4 @@ class TestMakeOutput(unittest.TestCase):
 
         # Check that the file name conflict is resolved and open is called for both
         final.open.assert_any_call("a_file", "wb")
-        final.open.assert_any_call("a_file_2", "wb")
\ No newline at end of file
+        final.open.assert_any_call("a_file_2", "wb")
index b78e89012ad62c5f952476da0553b2d26dac5fd3..cbd5ba1bc1a7b4c7052f40af80cb0ee874a2703b 100644 (file)
@@ -32,6 +32,13 @@ class TestPathmap(unittest.TestCase):
         self.api = mock.MagicMock()
         self.api._rootDesc = get_rootDesc()
 
+    def tearDown(self):
+        root_logger = logging.getLogger('')
+
+        # Remove existing RuntimeStatusLoggingHandlers if they exist
+        handlers = [h for h in root_logger.handlers if not isinstance(h, arvados_cwl.executor.RuntimeStatusLoggingHandler)]
+        root_logger.handlers = handlers
+
     def test_keepref(self):
         """Test direct keep references."""