This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 2eaeb01ee Make tests more robust - reset paramiko log level as part of 
setUp() and add additional assertions.
2eaeb01ee is described below

commit 2eaeb01ee95d8d4835053a84725670db69c6db49
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Mon Apr 15 21:43:10 2024 +0200

    Make tests more robust - reset paramiko log level as part of setUp() and
    add additional assertions.
---
 libcloud/test/test_init.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/test_init.py b/libcloud/test/test_init.py
index 6c393dec7..7eccd4550 100644
--- a/libcloud/test/test_init.py
+++ b/libcloud/test/test_init.py
@@ -39,13 +39,20 @@ _, TEMP_LOGFILE_PATH = tempfile.mkstemp()
 
 class TestUtils(unittest.TestCase):
     def setUp(self):
+        # Reset debug level
         reset_debug()
 
+        # Reset paramiko log level
+        if have_paramiko:
+            paramiko_logger = logging.getLogger("paramiko")
+            paramiko_logger.setLevel(logging.INFO)
+
     @mock.patch.dict(os.environ, {"LIBCLOUD_DEBUG": ""}, clear=True)
     def test_init_once_and_no_debug_mode(self):
         if have_paramiko:
             paramiko_logger = logging.getLogger("paramiko")
-            paramiko_logger.setLevel(logging.INFO)
+            paramiko_log_level = paramiko_logger.getEffectiveLevel()
+            self.assertEqual(paramiko_log_level, logging.INFO)
 
         self.assertIsNone(LoggingConnection.log)
         self.assertEqual(Connection.conn_class, LibcloudConnection)
@@ -64,7 +71,8 @@ class TestUtils(unittest.TestCase):
     def test_init_once_and_debug_mode(self):
         if have_paramiko:
             paramiko_logger = logging.getLogger("paramiko")
-            paramiko_logger.setLevel(logging.INFO)
+            paramiko_log_level = paramiko_logger.getEffectiveLevel()
+            self.assertEqual(paramiko_log_level, logging.INFO)
 
         self.assertIsNone(LoggingConnection.log)
         self.assertEqual(Connection.conn_class, LibcloudConnection)

Reply via email to