|
1 | 1 | from pssh import utils |
2 | 2 | import unittest |
3 | 3 | import os |
| 4 | +from logging import NullHandler |
4 | 5 | try: |
5 | 6 | from cStringIO import StringIO as BytesIO |
6 | 7 | except ImportError: |
|
14 | 15 | class ParallelSSHUtilsTest(unittest.TestCase): |
15 | 16 |
|
16 | 17 | def test_enabling_host_logger(self): |
| 18 | + self.assertTrue(len([h for h in utils.host_logger.handlers |
| 19 | + if isinstance(h, NullHandler)]) == 1) |
17 | 20 | 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 |
19 | 22 | 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) |
21 | 25 |
|
22 | 26 | def test_enabling_pssh_logger(self): |
| 27 | + self.assertTrue(len([h for h in utils.logger.handlers |
| 28 | + if isinstance(h, NullHandler)]) == 1) |
23 | 29 | 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 | + |
26 | 33 | def test_loading_key_files(self): |
27 | 34 | for key_filename in [PKEY_FILENAME, DSA_KEY_FILENAME, ECDSA_KEY_FILENAME]: |
28 | 35 | pkey = utils.load_private_key(key_filename) |
|
0 commit comments