pylint (test suite) - type comparison with isinstance()
This commit is contained in:
parent
7b32c412d5
commit
07d2d6dcb9
6 changed files with 14 additions and 14 deletions
|
|
@ -218,7 +218,7 @@ class MMGenPexpect:
|
|||
if cfg.debug_pexpect:
|
||||
debug_pexpect_msg(self.p)
|
||||
|
||||
if cfg.verbose and type(s) != str:
|
||||
if cfg.verbose and not isinstance(s,str):
|
||||
msg_r(f' ==> {ret} ')
|
||||
|
||||
if ret == -1:
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ def run_test(mod,test,arg,input_data,arg1,exc_name):
|
|||
kwargs = {}
|
||||
ret_chk = arg
|
||||
ret_idx = None
|
||||
if input_data == 'good' and type(arg) == tuple:
|
||||
if input_data == 'good' and isinstance(arg,tuple):
|
||||
arg,ret_chk = arg
|
||||
if type(arg) == dict: # pass one arg + kwargs to constructor
|
||||
if isinstance(arg,dict): # pass one arg + kwargs to constructor
|
||||
arg_copy = arg.copy()
|
||||
if 'arg' in arg:
|
||||
args = [arg['arg']]
|
||||
|
|
@ -89,7 +89,7 @@ def run_test(mod,test,arg,input_data,arg1,exc_name):
|
|||
del arg['ret_idx']
|
||||
del arg_copy['ret_idx']
|
||||
kwargs.update(arg)
|
||||
elif type(arg) == tuple:
|
||||
elif isinstance(arg,tuple):
|
||||
args = arg
|
||||
else:
|
||||
args = [arg]
|
||||
|
|
@ -103,7 +103,7 @@ def run_test(mod,test,arg,input_data,arg1,exc_name):
|
|||
|
||||
try:
|
||||
if not cfg.super_silent:
|
||||
arg_disp = repr(arg_copy[0] if type(arg_copy) == tuple else arg_copy)
|
||||
arg_disp = repr(arg_copy[0] if isinstance(arg_copy,tuple) else arg_copy)
|
||||
if cfg.test_suite_deterministic and isinstance(arg_copy,dict):
|
||||
arg_disp = re.sub(r'object at 0x[0-9a-f]+','object at [SCRUBBED]',arg_disp)
|
||||
msg_r((green if input_data=='good' else orange)(f'{arg_disp+":":<22}'))
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ def list_cmds():
|
|||
data = dpdata[cmd]
|
||||
yield ' {:{w}} - {}'.format(
|
||||
cmd,
|
||||
(data if type(data) == str else data[1]),
|
||||
(data if isinstance(data,str) else data[1]),
|
||||
w = cw )
|
||||
|
||||
w = max(map(len,utils))
|
||||
|
|
@ -454,7 +454,7 @@ class CmdGroupMgr:
|
|||
if hasattr(cls,'skip_cmds') and k in cls.skip_cmds:
|
||||
continue
|
||||
sdeps = get_shared_deps(k,i)
|
||||
if type(b) == str:
|
||||
if isinstance(b,str):
|
||||
cdata.append( (k, (i,f'{b} ({j}-bit)',[[[]+sdeps,i]])) )
|
||||
else:
|
||||
cdata.append( (k, (i,f'{b[1]} ({j}-bit)',[[b[0]+sdeps,i]])) )
|
||||
|
|
@ -954,7 +954,7 @@ class TestSuiteRunner:
|
|||
elif ret in ('skip','silent'):
|
||||
if ret == 'silent':
|
||||
self.cmd_total += 1
|
||||
elif type(ret) == tuple and ret[0] == 'skip_warn':
|
||||
elif isinstance(ret,tuple) and ret[0] == 'skip_warn':
|
||||
self.skipped_warnings.append(
|
||||
'Test {!r} was skipped:\n {}'.format(cmd,'\n '.join(ret[1].split('\n'))))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ skipped_tests = ['mn2hex_interactive']
|
|||
NL = ('\n','\r\n')[gc.platform=='win']
|
||||
|
||||
def is_str(s):
|
||||
return type(s) == str
|
||||
return isinstance(s,str)
|
||||
|
||||
from mmgen.key import is_wif
|
||||
from mmgen.addr import is_coin_addr
|
||||
|
|
@ -834,7 +834,7 @@ def check_output(out,chk):
|
|||
|
||||
if type(chk).__name__ == 'function':
|
||||
assert chk(outd), f'{chk.__name__}({outd}) failed!'
|
||||
elif type(chk) == dict:
|
||||
elif isinstance(chk,dict):
|
||||
for k,v in chk.items():
|
||||
if k == 'boolfunc':
|
||||
assert v(outd), f'{v.__name__}({outd}) failed!'
|
||||
|
|
@ -876,7 +876,7 @@ async def run_test(cls,gid,cmd_name):
|
|||
for d in data:
|
||||
args,out,opts,mmtype = d + tuple([None] * (4-len(d)))
|
||||
stdin_input = None
|
||||
if args and type(args[0]) == bytes:
|
||||
if args and isinstance(args[0],bytes):
|
||||
stdin_input = args[0]
|
||||
args[0] = '-'
|
||||
|
||||
|
|
@ -898,7 +898,7 @@ async def run_test(cls,gid,cmd_name):
|
|||
except:
|
||||
vmsg(f'Output:\n{cmd_out!r}\n')
|
||||
|
||||
if type(out) == tuple and type(out[0]).__name__ == 'function':
|
||||
if isinstance(out,tuple) and type(out[0]).__name__ == 'function':
|
||||
func_out = out[0](cmd_out)
|
||||
assert func_out == out[1],(
|
||||
'{}({}) == {} failed!\nOutput: {}'.format(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class unit_test:
|
|||
def test_passwords():
|
||||
for pw_base,res in pws:
|
||||
for pw in (pw_base,pw_base.encode()):
|
||||
pw_disp = "'"+pw+"'" if type(pw) == str else "b'"+pw.decode()+"'"
|
||||
pw_disp = "'"+pw+"'" if isinstance(pw,str) else "b'"+pw.decode()+"'"
|
||||
if cfg.quiet:
|
||||
omsg_r('.')
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class unit_tests:
|
|||
print_info(name,'Bitcoin Core test vectors')
|
||||
n = 1
|
||||
for e in core_data:
|
||||
if type(e[0]) == list:
|
||||
if isinstance(e[0],list):
|
||||
await test_tx(
|
||||
tx_proto = init_proto( cfg, 'btc', need_amt=True ),
|
||||
tx_hex = e[1],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue