@@ -116,27 +116,30 @@ def test_method_signatures(self):
116116 """Test that all methods have the same signature."""
117117 errors = {}
118118 cls = self .driver
119- attrs = [m for m in dir (cls )]
119+ # Create fictional driver instance (py3 needs bound methods)
120+ tmp_obj = cls (hostname = 'test' , username = 'admin' , password = 'pwd' )
121+ attrs = [m for m , v in inspect .getmembers (tmp_obj )]
120122 for attr in attrs :
121- func = getattr (cls , attr )
123+ func = getattr (tmp_obj , attr )
122124 if attr .startswith ('_' ) or not inspect .ismethod (func ):
123125 continue
124- orig = getattr (NetworkDriver , attr )
125-
126- orig_spec = inspect .getargspec (orig )
126+ try :
127+ orig = getattr (NetworkDriver , attr )
128+ orig_spec = inspect .getargspec (orig )
129+ except AttributeError :
130+ orig_spec = 'Method does not exist in napalm_base'
127131 func_spec = inspect .getargspec (func )
128132 if orig_spec != func_spec :
129133 errors [attr ] = (orig_spec , func_spec )
130134
131135 EXTRA_METHODS = ['__init__' , ]
132136 for method in EXTRA_METHODS :
133- if not method .startswith ('_' ):
134- orig_spec = inspect .getargspec (getattr (NetworkDriver , method ))
135- func_spec = inspect .getargspec (getattr (cls , method ))
136- if orig_spec != func_spec :
137- errors [attr ] = (orig_spec , func_spec )
137+ orig_spec = inspect .getargspec (getattr (NetworkDriver , method ))
138+ func_spec = inspect .getargspec (getattr (cls , method ))
139+ if orig_spec != func_spec :
140+ errors [attr ] = (orig_spec , func_spec )
138141
139- assert not errors , "Some method vary. \n {}" .format (errors )
142+ assert not errors , "Some methods vary. \n {}" .format (errors . keys () )
140143
141144 @wrap_test_cases
142145 def test_is_alive (self , test_case ):
0 commit comments