11from pssh import utils
22import unittest
33import os
4- from cStringIO import StringIO
4+ try :
5+ from cStringIO import StringIO as BytesIO
6+ except ImportError :
7+ from io import BytesIO
58from uuid import uuid4
69
710PKEY_FILENAME = os .path .sep .join ([os .path .dirname (__file__ ), 'test_client_private_key' ])
@@ -14,19 +17,19 @@ def test_enabling_host_logger(self):
1417 utils .enable_host_logger ()
1518 # And again to test only one handler is attached
1619 utils .enable_host_logger ()
17- self .assertTrue (len (utils .host_logger .handlers )== 1 )
20+ self .assertTrue (len (utils .host_logger .handlers ) == 1 )
1821
1922 def test_enabling_pssh_logger (self ):
2023 utils .enable_logger (utils .logger )
21- self .assertTrue (len (utils .logger .handlers )== 1 )
24+ self .assertTrue (len (utils .logger .handlers ) == 1 )
2225
2326 def test_loading_key_files (self ):
2427 for key_filename in [PKEY_FILENAME , DSA_KEY_FILENAME , ECDSA_KEY_FILENAME ]:
2528 pkey = utils .load_private_key (key_filename )
2629 self .assertTrue (pkey , msg = "Error loading key from file %s" % (key_filename ,))
2730 pkey = utils .load_private_key (open (key_filename ))
2831 self .assertTrue (pkey , msg = "Error loading key from open file object for file %s" % (key_filename ,))
29- fake_key = StringIO ( "blah blah fakey fakey key" )
32+ fake_key = BytesIO ( b "blah blah fakey fakey key" )
3033 self .assertFalse (utils .load_private_key (fake_key ))
3134
3235 def test_openssh_config_missing (self ):
0 commit comments