Fix paramiko test with pytest 3.4

The 3.4 pytest release introduced a breaking change: pytest no longer
changes log levels: the default log level is now Python's default:
WARNING. This commit ensures the test no longer depends on external log
levels.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/cdcd9823
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/cdcd9823
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/cdcd9823

Branch: refs/heads/trunk
Commit: cdcd98235105132dfc2d88a91d657b0ce29a0056
Parents: e7429e9
Author: Quentin Pradet <quent...@apache.org>
Authored: Fri Feb 2 15:57:27 2018 +0400
Committer: Anthony Shaw <anthonys...@apache.org>
Committed: Sat Feb 3 12:03:55 2018 +0800

----------------------------------------------------------------------
 libcloud/test/test_init.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cdcd9823/libcloud/test/test_init.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_init.py b/libcloud/test/test_init.py
index d088cb9..5a8db75 100644
--- a/libcloud/test/test_init.py
+++ b/libcloud/test/test_init.py
@@ -33,14 +33,17 @@ from libcloud.test import unittest
 
 class TestUtils(unittest.TestCase):
     def test_init_once_and_debug_mode(self):
+        if have_paramiko:
+            paramiko_logger = paramiko.util.logging.getLogger()
+            paramiko_logger.setLevel(logging.NOTSET)
+
         # Debug mode is disabled
         _init_once()
 
         self.assertEqual(LoggingConnection.log, None)
 
         if have_paramiko:
-            logger = paramiko.util.logging.getLogger()
-            paramiko_log_level = logger.getEffectiveLevel()
+            paramiko_log_level = paramiko_logger.getEffectiveLevel()
             self.assertEqual(paramiko_log_level, logging.NOTSET)
 
         # Enable debug mode
@@ -50,8 +53,7 @@ class TestUtils(unittest.TestCase):
         self.assertTrue(LoggingConnection.log is not None)
 
         if have_paramiko:
-            logger = paramiko.util.logging.getLogger()
-            paramiko_log_level = logger.getEffectiveLevel()
+            paramiko_log_level = paramiko_logger.getEffectiveLevel()
             self.assertEqual(paramiko_log_level, logging.DEBUG)
 
     def test_factory(self):

Reply via email to