1
1
from pssh import utils
2
2
import unittest
3
3
import os
4
- from cStringIO import StringIO
4
+ try :
5
+ from cStringIO import StringIO as BytesIO
6
+ except ImportError :
7
+ from io import BytesIO
5
8
from uuid import uuid4
6
9
7
10
PKEY_FILENAME = os .path .sep .join ([os .path .dirname (__file__ ), 'test_client_private_key' ])
@@ -14,19 +17,19 @@ def test_enabling_host_logger(self):
14
17
utils .enable_host_logger ()
15
18
# And again to test only one handler is attached
16
19
utils .enable_host_logger ()
17
- self .assertTrue (len (utils .host_logger .handlers )== 1 )
20
+ self .assertTrue (len (utils .host_logger .handlers ) == 1 )
18
21
19
22
def test_enabling_pssh_logger (self ):
20
23
utils .enable_logger (utils .logger )
21
- self .assertTrue (len (utils .logger .handlers )== 1 )
24
+ self .assertTrue (len (utils .logger .handlers ) == 1 )
22
25
23
26
def test_loading_key_files (self ):
24
27
for key_filename in [PKEY_FILENAME , DSA_KEY_FILENAME , ECDSA_KEY_FILENAME ]:
25
28
pkey = utils .load_private_key (key_filename )
26
29
self .assertTrue (pkey , msg = "Error loading key from file %s" % (key_filename ,))
27
30
pkey = utils .load_private_key (open (key_filename ))
28
31
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" )
30
33
self .assertFalse (utils .load_private_key (fake_key ))
31
34
32
35
def test_openssh_config_missing (self ):
0 commit comments