Skip to content

Commit 59fcd93

Browse files
author
Dan
committed
Updated utils tests to check for null and non-null handlers before and after enabling loggers respectively
1 parent 2e7b811 commit 59fcd93

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/test_utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pssh import utils
22
import unittest
33
import os
4+
from logging import NullHandler
45
try:
56
from cStringIO import StringIO as BytesIO
67
except ImportError:
@@ -14,15 +15,21 @@
1415
class ParallelSSHUtilsTest(unittest.TestCase):
1516

1617
def test_enabling_host_logger(self):
18+
self.assertTrue(len([h for h in utils.host_logger.handlers
19+
if isinstance(h, NullHandler)]) == 1)
1720
utils.enable_host_logger()
18-
# And again to test only one handler is attached
21+
# And again to test only one non-null handler is attached
1922
utils.enable_host_logger()
20-
self.assertTrue(len(utils.host_logger.handlers) == 1)
23+
self.assertTrue(len([h for h in utils.host_logger.handlers
24+
if not isinstance(h, NullHandler)]) == 1)
2125

2226
def test_enabling_pssh_logger(self):
27+
self.assertTrue(len([h for h in utils.logger.handlers
28+
if isinstance(h, NullHandler)]) == 1)
2329
utils.enable_logger(utils.logger)
24-
self.assertTrue(len(utils.logger.handlers) == 1)
25-
30+
self.assertTrue(len([h for h in utils.host_logger.handlers
31+
if not isinstance(h, NullHandler)]) == 1)
32+
2633
def test_loading_key_files(self):
2734
for key_filename in [PKEY_FILENAME, DSA_KEY_FILENAME, ECDSA_KEY_FILENAME]:
2835
pkey = utils.load_private_key(key_filename)

0 commit comments

Comments
 (0)