1
- import sys , unittest , re , os .path
1
+ import sys
2
+ import unittest
3
+ import re
4
+ import os .path
2
5
sys .path .insert (0 , os .path .join (os .path .dirname (__file__ ), '..' , '..' ))
3
6
4
- from Exscript import Host , Account
7
+ from Exscript import Host , Account
5
8
from Exscript .util .url import Url
6
- from util .urlTest import urls
9
+ from util .urlTest import urls
10
+
7
11
8
12
class HostTest (unittest .TestCase ):
9
13
CORRELATE = Host
10
14
11
15
def setUp (self ):
12
16
self .host = Host ('localhost' )
13
- self .host .set_all (dict (testarg = 1 ))
17
+ self .host .set_all (dict (testarg = 1 ))
14
18
15
19
def testConstructor (self ):
16
20
host = Host ('localhost' )
17
21
self .assertEqual (host .get_protocol (), 'telnet' )
18
- host = Host ('localhost' , default_protocol = 'foo' )
22
+ host = Host ('localhost' , default_protocol = 'foo' )
19
23
self .assertEqual (host .get_protocol (), 'foo' )
20
24
21
25
for url , result in urls :
22
26
host = Host (url )
23
- uri = Url .from_string (url )
27
+ uri = Url .from_string (url )
24
28
self .assertEqual (host .get_name (), uri .hostname )
25
29
self .assertEqual (host .get_address (), uri .hostname )
26
30
self .assertEqual (host .get_uri (), str (uri ))
@@ -35,7 +39,7 @@ def testSetUri(self):
35
39
def testGetUri (self ):
36
40
for url , result in urls :
37
41
host = Host (url )
38
- uri = Url .from_string (url )
42
+ uri = Url .from_string (url )
39
43
self .assertEqual (host .get_uri (), str (uri ))
40
44
41
45
def testGetDict (self ):
@@ -73,30 +77,31 @@ def testSetName(self):
73
77
self .assertEqual (self .host .get_name (), 'testhost' )
74
78
75
79
def testGetName (self ):
76
- pass # Tested in testSetName().
80
+ pass # Tested in testSetName().
77
81
78
82
def testSetProtocol (self ):
79
83
self .assertEqual (self .host .get_protocol (), 'telnet' )
80
84
self .host .set_protocol ('dummy' )
81
85
self .assertEqual (self .host .get_protocol (), 'dummy' )
82
86
83
87
def testGetProtocol (self ):
84
- pass # Tested in testSetProtocol().
88
+ pass # Tested in testSetProtocol().
85
89
86
90
def testSetOption (self ):
87
91
self .assertRaises (TypeError , self .host .set_option , 'test' , True )
88
92
self .assertEqual (self .host .get_options (), {})
89
93
self .assertEqual (self .host .get_option ('verify_fingerprint' ), None )
90
- self .assertEqual (self .host .get_option ('verify_fingerprint' , False ), False )
94
+ self .assertEqual (
95
+ self .host .get_option ('verify_fingerprint' , False ), False )
91
96
self .host .set_option ('verify_fingerprint' , True )
92
97
self .assertEqual (self .host .get_option ('verify_fingerprint' ), True )
93
98
self .assertEqual (self .host .get_options (), {'verify_fingerprint' : True })
94
99
95
100
def testGetOption (self ):
96
- pass # Tested in testSetOption().
101
+ pass # Tested in testSetOption().
97
102
98
103
def testGetOptions (self ):
99
- pass # Tested in testSetOption().
104
+ pass # Tested in testSetOption().
100
105
101
106
def testSetTcpPort (self ):
102
107
self .assertEqual (self .host .get_tcp_port (), 23 )
@@ -106,7 +111,7 @@ def testSetTcpPort(self):
106
111
self .assertEqual (self .host .get_tcp_port (), 123 )
107
112
108
113
def testGetTcpPort (self ):
109
- pass # Tested in testSetTcpPort().
114
+ pass # Tested in testSetTcpPort().
110
115
111
116
def testSetAccount (self ):
112
117
account = Account ('test' )
@@ -115,7 +120,7 @@ def testSetAccount(self):
115
120
self .assertEqual (self .host .get_account (), account )
116
121
117
122
def testGetAccount (self ):
118
- pass # Tested in testSetAccount().
123
+ pass # Tested in testSetAccount().
119
124
120
125
def testSet (self ):
121
126
self .assertEqual (self .host .get ('test' ), None )
@@ -165,7 +170,8 @@ def testGet(self):
165
170
self .assertEqual (self .host .get ('test' , 1 ), 3 )
166
171
self .assertEqual (self .host .get ('test2' , 1 ), 1 )
167
172
173
+
168
174
def suite ():
169
175
return unittest .TestLoader ().loadTestsFromTestCase (HostTest )
170
176
if __name__ == '__main__' :
171
- unittest .TextTestRunner (verbosity = 2 ).run (suite ())
177
+ unittest .TextTestRunner (verbosity = 2 ).run (suite ())
0 commit comments