Browse Source

pylint (test suite) - imports

The MMGen Project 1 year ago
parent
commit
7b32c412d5

+ 1 - 1
scripts/create-token.py

@@ -20,7 +20,7 @@
 scripts/create-token.py: Automated ERC20 token creation for the MMGen suite
 """
 
-import sys,os,json,re
+import sys,json,re
 from subprocess import run,PIPE
 from collections import namedtuple
 

+ 10 - 9
scripts/tx-v2-to-v3.py

@@ -1,13 +1,17 @@
 #!/usr/bin/env python3
-# Convert MMGen 'v2' transaction file (amounts as BTCAmt())
-# to MMGen 'v3' (amounts as strings)
-# v3 tx files were introduced with MMGen version 0.9.7
 
-import sys,os
-repo_root = os.path.split(os.path.abspath(os.path.dirname(sys.argv[0])))[0]
-sys.path = [repo_root] + sys.path
+"""
+Convert an MMGen 'v2' transaction file (amounts as BTCAmt()) to 'v3' (amounts as
+strings).  Version 3 TX files were introduced with MMGen version 0.9.7
+"""
+
+import sys,os,asyncio
 
 from mmgen.cfg import Config
+from mmgen.tx import CompletedTX
+
+repo_root = os.path.split(os.path.abspath(os.path.dirname(sys.argv[0])))[0]
+sys.path = [repo_root] + sys.path
 
 opts_data = {
 	'text': {
@@ -24,9 +28,6 @@ opts_data = {
 
 cfg = Config(opts_data=opts_data)
 
-import asyncio
-from mmgen.tx import CompletedTX
-
 if len(cfg._args) != 1:
 	cfg._opts.usage()
 

+ 1 - 3
test/gentest.py

@@ -25,7 +25,6 @@ import sys,os,time
 import include.test_init
 
 # Import these _after_ local path's been added to sys.path
-import mmgen.opts as opts
 from mmgen.cfg import gc,Config
 from mmgen.color import green,red,purple
 from mmgen.util import msg,ymsg,capfirst,is_int,die
@@ -419,11 +418,10 @@ def speed_test(proto,kg,ag,rounds):
 	qmsg(green('Testing speed of address generator {!r} for coin {}'.format(
 		type(kg).__name__,
 		proto.coin )))
-	from struct import pack,unpack
+	from struct import pack
 	seed = getrand(28)
 	qmsg('Incrementing key with each round')
 	qmsg('Starting key: {}'.format( (seed + pack('I',0)).hex() ))
-	import time
 	start = last_t = time.time()
 
 	for i in range(rounds):

+ 2 - 2
test/hashfunc.py

@@ -20,9 +20,9 @@
 test/hashfunc.py: Test internal implementations of SHA256, SHA512 and Keccak256
 """
 
-import sys,os
+import sys
 import include.test_init
-from mmgen.util import die,ymsg
+from mmgen.util import die
 
 assert len(sys.argv) in (2,3),"Test takes 1 or 2 arguments: test name, plus optional rounds count"
 test = sys.argv[1].capitalize()

+ 1 - 1
test/include/pexpect.py

@@ -20,7 +20,7 @@
 test.include.pexpect: pexpect implementation for MMGen test suites
 """
 
-import sys,os,time
+import sys,time
 from mmgen.color import red,yellow,green,cyan
 from mmgen.util import msg,msg_r,rmsg,die
 from .common import cfg,vmsg,vmsg_r,getrandstr,strip_ansi_escapes

+ 1 - 1
test/misc/tool_api_test.py

@@ -7,7 +7,7 @@
 test.misc.tool_api_test: test the MMGen suite tool API
 """
 
-import sys,os
+import sys
 from mmgen.key import PrivKey
 from mmgen.addr import CoinAddr
 

+ 1 - 2
test/objattrtest.py

@@ -22,7 +22,6 @@ test/objattrtest.py: Test immutable attributes of MMGen data objects
 
 # TODO: test 'typeconv' during instance creation
 
-import sys,os
 from collections import namedtuple
 
 import include.test_init
@@ -30,7 +29,7 @@ import include.test_init
 from mmgen.cfg import Config
 from mmgen.util import msg,msg_r,gmsg,die
 from mmgen.color import red,yellow,green,blue,purple,nocolor
-from mmgen.obj import ImmutableAttr,ListItemAttr
+from mmgen.obj import ListItemAttr
 
 opts_data = {
 	'sets': [

+ 3 - 3
test/objattrtest_py_d/oat_common.py

@@ -8,8 +8,7 @@ test.objattrtest_py_d.oat_common: shared data for MMGen data objects tests
 """
 
 from decimal import Decimal
-
-from ..include.common import cfg,getrand
+from collections import namedtuple
 
 from mmgen.obj import TwComment,CoinTxID,HexStr
 from mmgen.seed import Seed,SeedID
@@ -17,7 +16,8 @@ from mmgen.subseed import SubSeedIdx,SubSeedList
 from mmgen.seedsplit import SeedShareList,SeedShareCount,SeedSplitIDString,SeedShareIdx,MasterShareIdx
 from mmgen.addr import AddrIdx
 
-from collections import namedtuple
+from ..include.common import cfg,getrand
+
 atd = namedtuple('attrtest_entry',['attrs','args','kwargs'])
 
 seed_bin = getrand(32)

+ 1 - 1
test/objtest.py

@@ -20,7 +20,7 @@
 test/objtest.py: Test MMGen data objects
 """
 
-import sys,os,re
+import os,re
 
 import include.test_init
 

+ 5 - 5
test/objtest_py_d/ot_btc_mainnet.py

@@ -9,21 +9,21 @@ test.objtest_py_d.ot_btc_mainnet: BTC mainnet test vectors for MMGen data object
 
 from decimal import Decimal
 
-from .ot_common import r16,r32
-from ..include.common import cfg,utf8_ctrl,utf8_text,utf8_combining,gr_uc_w_ctrl,text_jp,text_zh,ru_uc,gr_uc
-
 from mmgen.obj import Int,MMGenTxID,CoinTxID,MMGenWalletLabel,MMGenTxComment,MMGenPWIDString
 from mmgen.addrlist import AddrIdx,AddrIdxList,AddrListID
 from mmgen.seed import Seed,SeedID
-from mmgen.seedsplit import SeedShareIdx,SeedShareCount,SubSeedList,MasterShareIdx,SeedSplitSpecifier
 from mmgen.subseed import SubSeedList,SubSeedIdx,SubSeedIdxRange
+from mmgen.seedsplit import SeedShareIdx,SeedShareCount,MasterShareIdx,SeedSplitSpecifier
 from mmgen.key import PrivKey,WifKey,PubKey
 from mmgen.amt import BTCAmt
 from mmgen.addr import CoinAddr,MMGenID,MMGenAddrType,MMGenPasswordType
 from mmgen.tw.shared import TwMMGenID,TwLabel,TwComment
 from mmgen.rpc import IPPort
-
 from mmgen.protocol import init_proto
+
+from .ot_common import r16,r32
+from ..include.common import cfg,utf8_ctrl,utf8_text,utf8_combining,gr_uc_w_ctrl,text_jp,text_zh,ru_uc,gr_uc
+
 proto = init_proto( cfg, 'btc', need_amt=True )
 tw_pfx = proto.base_coin.lower() + ':'
 zero_addr = '1111111111111111111114oLvT2'

+ 4 - 4
test/objtest_py_d/ot_btc_testnet.py

@@ -7,13 +7,13 @@
 test.objtest_py_d.ot_btc_testnet: BTC testnet test vectors for MMGen data objects
 """
 
-from .ot_common import r16,r32
-from ..include.common import cfg
-
 from mmgen.key import PrivKey,WifKey
 from mmgen.addr import CoinAddr
-
 from mmgen.protocol import init_proto
+
+from .ot_common import r16,r32
+from ..include.common import cfg
+
 proto = init_proto( cfg, 'btc', network='testnet', need_amt=True )
 
 tests = {

+ 4 - 4
test/objtest_py_d/ot_ltc_mainnet.py

@@ -9,14 +9,14 @@ test.objtest_py_d.ot_ltc_mainnet: LTC mainnet test vectors for MMGen data object
 
 from decimal import Decimal
 
-from .ot_common import r16,r32
-from ..include.common import cfg
-
 from mmgen.amt import LTCAmt
 from mmgen.addr import CoinAddr
 from mmgen.key import WifKey,PrivKey
-
 from mmgen.protocol import init_proto
+
+from .ot_common import r16,r32
+from ..include.common import cfg
+
 proto = init_proto( cfg, 'ltc', need_amt=True )
 
 tests = {

+ 4 - 4
test/objtest_py_d/ot_ltc_testnet.py

@@ -7,13 +7,13 @@
 test.objtest_py_d.ot_ltc_testnet: LTC testnet test vectors for MMGen data objects
 """
 
-from .ot_common import r16,r32
-from ..include.common import cfg
-
 from mmgen.addr import CoinAddr
 from mmgen.key import WifKey,PrivKey
-
 from mmgen.protocol import init_proto
+
+from .ot_common import r16,r32
+from ..include.common import cfg
+
 proto = init_proto( cfg, 'ltc', network='testnet', need_amt=True )
 
 tests = {

+ 2 - 1
test/overlay/fakemods/mmgen/tw/view.py

@@ -1,7 +1,8 @@
 import os as overlay_fake_os
-from .view_orig import *
 import mmgen.tw.view_orig as overlay_fake_orig_mod
 
+from .view_orig import *
+
 overlay_fake_orig_mod.CUR_HOME  = '\n[CUR_HOME]\n'
 overlay_fake_orig_mod.CUR_UP    = lambda n: f'\n[CUR_UP({n})]\n'
 overlay_fake_orig_mod.CUR_DOWN  = lambda n: f'\n[CUR_DOWN({n})]\n'

+ 3 - 4
test/scrambletest.py

@@ -21,12 +21,12 @@ test/scrambletest.py: seed scrambling and addrlist data generation tests for all
                       supported coins + passwords
 """
 
-import sys,os,time
+import os,time
 from subprocess import run,PIPE
+from collections import namedtuple
 
 import include.test_init
 
-import mmgen.opts as opts
 from mmgen.cfg import gc,Config
 from mmgen.util import msg,msg_r,bmsg,die
 
@@ -51,11 +51,10 @@ If no command is given, the whole suite of tests is run.
 
 cfg = Config(opts_data=opts_data)
 
-from test.include.common import set_globals,end_msg,green
+from test.include.common import set_globals,init_coverage,end_msg,green
 
 set_globals(cfg)
 
-from collections import namedtuple
 td = namedtuple('scrambletest_entry',['seed','str','id_str','lbl','addr'])
 
 bitcoin_data = {

+ 1 - 1
test/test_py_d/input.py

@@ -10,7 +10,7 @@
 test.test_py_d.input: Shared input routines for the test.py test suite
 """
 
-import os,time
+import time
 from .common import randbool
 from ..include.common import getrand
 

+ 2 - 3
test/test_py_d/ts_autosign.py

@@ -27,6 +27,8 @@ from pathlib import Path
 from mmgen.cfg import gc
 from mmgen.color import red,green,blue,purple
 from mmgen.util import msg,suf,die
+from mmgen.led import LEDControl
+from mmgen.autosign import Autosign,AutosignConfig
 
 from ..include.common import (
 	cfg,
@@ -43,9 +45,6 @@ from .common import ref_dir,dfl_words_file,dfl_bip39_file
 from .ts_base import TestSuiteBase
 from .input import stealth_mnemonic_entry
 
-from mmgen.led import LEDControl
-from mmgen.autosign import Autosign,AutosignConfig
-
 filedir_map = (
 	('btc',''),
 	('bch',''),

+ 3 - 3
test/test_py_d/ts_cfgfile.py

@@ -12,13 +12,13 @@ test.test_py_d.ts_cfgfile: CfgFile tests for the MMGen test.py test suite
 
 import os,time,shutil
 
-from ..include.common import cfg,read_from_file,write_to_file,imsg
-from .ts_base import TestSuiteBase
-
 from mmgen.cfg import gc
 from mmgen.color import yellow
 from mmgen.cfgfile import CfgFileSampleSys,CfgFileSampleUsr,cfg_file_sample
 
+from ..include.common import cfg,read_from_file,write_to_file,imsg
+from .ts_base import TestSuiteBase
+
 class TestSuiteCfgFile(TestSuiteBase):
 	'CfgFile API'
 	networks = ('btc',)

+ 0 - 2
test/test_py_d/ts_chainsplit.py

@@ -21,8 +21,6 @@ test.test_py_d.ts_chainsplit: Forking scenario tests for the test.py test suite
 This module is unmaintained and currently non-functional
 """
 
-import os
-
 from mmgen.util import die
 
 from .common import get_file_with_ext

+ 1 - 2
test/test_py_d/ts_ethdev.py

@@ -20,7 +20,7 @@
 test.test_py_d.ts_ethdev: Ethdev tests for the test.py test suite
 """
 
-import sys,os,re,shutil,asyncio,json
+import os,re,shutil,asyncio,json
 from decimal import Decimal
 from collections import namedtuple
 from subprocess import run,PIPE,DEVNULL
@@ -28,7 +28,6 @@ from subprocess import run,PIPE,DEVNULL
 from mmgen.cfg import gc
 from mmgen.color import yellow,blue,cyan,set_vt100
 from mmgen.util import msg,rmsg,die
-from mmgen.protocol import CoinProtocol
 
 from ..include.common import (
 	cfg,

+ 5 - 6
test/test_py_d/ts_input.py

@@ -10,7 +10,11 @@
 test.test_py_d.ts_input: user input tests for the MMGen test.py test suite
 """
 
-import os,time
+import os
+
+from mmgen.cfg import gc
+from mmgen.util import fmt,capfirst,remove_whitespace
+from mmgen.wallet import get_wallet_cls
 
 from ..include.common import (
 	cfg,
@@ -25,11 +29,6 @@ from .common import Ctrl_U,ref_dir
 from .ts_base import TestSuiteBase
 from .input import stealth_mnemonic_entry,user_dieroll_entry
 
-from mmgen.cfg import gc
-from mmgen.color import set_vt100
-from mmgen.util import fmt,capfirst,remove_whitespace
-from mmgen.wallet import get_wallet_cls
-
 class TestSuiteInput(TestSuiteBase):
 	'user input'
 	networks = ('btc',)

+ 1 - 1
test/test_py_d/ts_opts.py

@@ -10,7 +10,7 @@
 test.test_py_d.ts_opts: options processing tests for the MMGen test.py test suite
 """
 
-import os
+import os,time
 
 from ..include.common import cfg
 from .ts_base import TestSuiteBase

+ 0 - 1
test/test_py_d/ts_ref.py

@@ -30,7 +30,6 @@ from ..include.common import (
 	ok,
 	joinpath,
 	cmp_or_die,
-	ref_kafile_hash_preset,
 	ref_kafile_pass,
 	read_from_file,
 	sample_text

+ 0 - 2
test/test_py_d/ts_ref_altcoin.py

@@ -20,8 +20,6 @@
 test.test_py_d.ts_ref_altcoin: Altcoin reference file tests for the test.py test suite
 """
 
-import os
-
 from mmgen.color import set_vt100
 
 from .common import pwfile,dfl_wpasswd,ref_dir,dfl_words_file,dfl_addr_idx_list

+ 1 - 1
test/test_py_d/ts_regtest.py

@@ -24,7 +24,7 @@ import os,json,time,re
 from decimal import Decimal
 
 from mmgen.color import yellow
-from mmgen.util import msg_r,die,gmsg,capfirst,fmt_list,async_run
+from mmgen.util import msg_r,die,gmsg,capfirst,fmt_list
 from mmgen.protocol import init_proto
 from mmgen.addrlist import AddrList
 from mmgen.wallet import Wallet,get_wallet_cls

+ 1 - 3
test/test_py_d/ts_shared.py

@@ -20,9 +20,7 @@
 test.test_py_d.ts_shared: Shared methods for the test.py test suite
 """
 
-import os
-
-from mmgen.util import ymsg,get_extension
+from mmgen.util import get_extension
 from mmgen.wallet import get_wallet_cls
 
 from ..include.common import cmp_or_die,strip_ansi_escapes,joinpath

+ 1 - 1
test/test_py_d/ts_xmrwallet.py

@@ -20,7 +20,7 @@
 test.test_py_d.ts_xmrwallet: xmrwallet tests for the test.py test suite
 """
 
-import sys,os,time,re,atexit,asyncio,shutil
+import os,time,re,atexit,asyncio,shutil
 from subprocess import run,PIPE
 from collections import namedtuple
 

+ 3 - 3
test/tooltest.py

@@ -20,7 +20,7 @@
 test/tooltest.py: Tests for the 'mmgen-tool' utility
 """
 
-import sys,os,binascii
+import sys,os,time
 from subprocess import run,PIPE
 
 import include.test_init
@@ -66,7 +66,8 @@ from test.include.common import (
 	getrand,
 	getrandhex,
 	end_msg,
-	init_coverage
+	init_coverage,
+	get_tmpfile,
 )
 set_globals(cfg)
 
@@ -460,7 +461,6 @@ class MMGenToolTestCmds:
 		ok()
 
 # main()
-import time
 start_time = int(time.time())
 mk_tmpdir(tcfg['tmpdir'])
 

+ 1 - 1
test/tooltest2.py

@@ -963,7 +963,7 @@ if cfg.tool_api:
 	del tests['Wallet']
 	del tests['File']
 
-import mmgen.main_tool as main_tool
+from mmgen import main_tool
 
 if cfg.list_tests:
 	Msg('Available tests:')

+ 1 - 2
test/unit_tests_d/ut_daemon.py

@@ -4,13 +4,12 @@
 test.unit_tests_d.ut_daemon: unit test for the MMGen suite's Daemon class
 """
 
-from subprocess import run,DEVNULL,PIPE
+from subprocess import run,PIPE
 from collections import namedtuple
 
 from mmgen.color import orange
 from mmgen.util import fmt_list
 from mmgen.daemon import CoinDaemon
-from mmgen.protocol import init_proto
 
 from ..include.common import cfg,qmsg,qmsg_r,vmsg
 

+ 2 - 1
test/unit_tests_d/ut_msg.py

@@ -6,12 +6,13 @@ test.unit_tests_d.ut_msg: message signing unit tests for the MMGen suite
 
 import os
 
-from ..include.common import cfg,silence,end_silence,restart_test_daemons,stop_test_daemons
 from mmgen.util import msg,bmsg,pumsg,suf
 from mmgen.protocol import CoinProtocol
 from mmgen.msg import NewMsg,UnsignedMsg,SignedMsg,SignedOnlineMsg,ExportedMsgSigs
 from mmgen.addr import MMGenID
 
+from ..include.common import cfg,silence,end_silence,restart_test_daemons,stop_test_daemons
+
 def get_obj(coin,network,msghash_type):
 
 	if coin == 'bch':

+ 2 - 1
test/unit_tests_d/ut_scrypt.py

@@ -4,9 +4,10 @@
 test.unit_tests_d.ut_scrypt: password hashing unit test for the MMGen suite
 """
 
-from ..include.common import cfg,qmsg,vmsg,omsg_r,silence,end_silence
 from mmgen.util import msg,msg_r
 
+from ..include.common import cfg,qmsg,vmsg,omsg_r,silence,end_silence
+
 class unit_test:
 
 	def run_test(self,name,ut):

+ 0 - 1
test/unit_tests_d/ut_tx_deserialize.py

@@ -12,7 +12,6 @@ from mmgen.protocol import init_proto
 from mmgen.tx import CompletedTX
 from mmgen.proto.btc.tx.base import DeserializeTX
 from mmgen.rpc import rpc_init
-from mmgen.daemon import CoinDaemon
 
 from ..include.common import cfg,start_test_daemons,stop_test_daemons
 

+ 3 - 2
test/unit_tests_d/ut_util.py

@@ -4,9 +4,10 @@
 test.unit_tests_d.ut_misc: utility unit tests for the MMGen suite
 """
 
-from ..include.common import vmsg
-from mmgen.util import fmt_list,fmt_dict,list_gen
 from mmgen.color import cyan
+from mmgen.util import fmt_list,fmt_dict,list_gen
+
+from ..include.common import vmsg
 
 class unit_tests: