From d2a3e2279056a678ff1cbd91dfc220bf76eb12f3 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 31 Oct 2022 15:42:09 +0000 Subject: [PATCH] minor cleanups --- mmgen/proto/btc/tw/txhistory.py | 2 +- test/test_py_d/ts_cfg.py | 2 +- test/test_py_d/ts_misc.py | 37 ++++++++++++++++++++++++--------- test/test_py_d/ts_regtest.py | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/mmgen/proto/btc/tw/txhistory.py b/mmgen/proto/btc/tw/txhistory.py index d5295c72..a974549a 100755 --- a/mmgen/proto/btc/tw/txhistory.py +++ b/mmgen/proto/btc/tw/txhistory.py @@ -17,7 +17,7 @@ from ....globalvars import g from ....tw.txhistory import TwTxHistory from ....tw.common import get_tw_label,TwMMGenID from ....addr import CoinAddr -from ....util import msg,msg_r,remove_dups +from ....util import msg,msg_r from ....color import nocolor,red,pink,gray from ....obj import TwComment,CoinTxID,Int from .common import BitcoinTwCommon diff --git a/test/test_py_d/ts_cfg.py b/test/test_py_d/ts_cfg.py index 53a9c6dc..6bb5dcd0 100755 --- a/test/test_py_d/ts_cfg.py +++ b/test/test_py_d/ts_cfg.py @@ -7,7 +7,7 @@ # Licensed according to the terms of GPL Version 3. See LICENSE for details. """ -ts_misc.py: CfgFile tests for the MMGen test.py test suite +ts_cfg.py: CfgFile tests for the MMGen test.py test suite """ import shutil diff --git a/test/test_py_d/ts_misc.py b/test/test_py_d/ts_misc.py index c6a393e7..4d30c8fb 100755 --- a/test/test_py_d/ts_misc.py +++ b/test/test_py_d/ts_misc.py @@ -82,6 +82,15 @@ class TestSuiteHelp(TestSuiteBase): t.expect('MMGEN-TOOL version') return t + def spawn_chk_expect(self,*args,**kwargs): + expect = kwargs.pop('expect') + t = self.spawn(*args,**kwargs) + t.expect(expect) + t.read() + t.ok() + t.skip_ok = True + return t + def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:'): scripts = list(scripts) or [s.replace('mmgen-','') for s in os.listdir('cmds')] @@ -119,12 +128,15 @@ class TestSuiteHelp(TestSuiteBase): ymsg('Skipping tool help with PYTHONOPTIMIZE=2 (no docstrings)') return 'skip' - for args in ( - ['help'], - ['usage'], - ['help','randpair'] + for arg in ( + 'help', + 'usage', ): - t = self.spawn_chk('mmgen-tool',args,extra_desc=f"('mmgen-tool {fmt_list(args,fmt='bare')}')") + t = self.spawn_chk_expect( + 'mmgen-tool', + [arg], + extra_desc = f'(mmgen-tool {arg})', + expect = 'GENERAL USAGE' ) return t def tool_cmd_usage(self): @@ -141,12 +153,17 @@ class TestSuiteHelp(TestSuiteBase): return t def test_help(self): - for args in ( - ['--help'], - ['--list-cmds'], - ['--list-cmd-groups'] + for arg,expect in ( + ('--help','USAGE'), + ('--list-cmds','AVAILABLE COMMANDS'), + ('--list-cmd-groups','AVAILABLE COMMAND GROUPS') ): - t = self.spawn_chk('test.py',args,cmd_dir='test',extra_desc=f"('test.py {fmt_list(args,fmt='bare')}')") + t = self.spawn_chk_expect( + 'test.py', + [arg], + cmd_dir = 'test', + extra_desc = f'(test.py {arg})', + expect = expect ) return t class TestSuiteOutput(TestSuiteBase): diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index f9792cea..fa9679ab 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -867,7 +867,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): txfile = self.get_file_with_ext(ext,delete=False,no_dot=True) return self.user_txbump('bob',self.tmpdir,txfile,rtFee[2],add_args=['--send']) - def generate(self,coin=None,num_blocks=1): + def generate(self,num_blocks=1): int(num_blocks) t = self.spawn('mmgen-regtest',['generate',str(num_blocks)]) t.expect(f'Mined {num_blocks} block')