Browse Source

minor fixes and cleanups

The MMGen Project 3 years ago
parent
commit
4453aaf355

+ 2 - 1
mmgen/tw.py

@@ -406,7 +406,8 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view, add [l]abel:
 		msg('')
 		while True:
 			ret = line_input(f'Enter {self.item_desc} number (or RETURN to return to main menu): ')
-			if ret == '': return (None,None) if action == 'a_lbl_add' else None
+			if ret == '':
+				return (None,None) if action == 'a_lbl_add' else None
 			n = get_obj(AddrIdx,n=ret,silent=True)
 			if not n or n < 1 or n > len(self.unspent):
 				msg(f'Choice must be a single number between 1 and {len(self.unspent)}')

+ 1 - 1
mmgen/util.py

@@ -797,7 +797,7 @@ def line_input(prompt,echo=True,insert_txt=''):
 	if g.test_suite_popen_spawn:
 		msg(prompt)
 		sys.stderr.flush()
-		reply = os.read(0,4096).decode()
+		reply = os.read(0,4096).decode().rstrip('\n') # strip NL to mimic behavior of input()
 	elif echo or not sys.stdin.isatty():
 		clear_buffer = init_readline() if sys.stdin.isatty() else False
 		reply = input(prompt)

+ 1 - 1
test/test.py

@@ -608,7 +608,7 @@ class CmdGroupMgr(object):
 							and g[0] in tuple(self.cmd_groups_dfl) + tuple(usr_args) ]
 
 		for name,cls in ginfo:
-			msg(f'{name:17} - {cls.__doc__}')
+			msg(f'{name:17} - {cls.__doc__.strip()}')
 
 		Die(0,'\n'+' '.join(e[0] for e in ginfo))
 

+ 3 - 2
test/test_py_d/ts_cfg.py

@@ -118,9 +118,12 @@ class TestSuiteCfg(TestSuiteBase):
 				t.expect(s)
 
 		cp = CfgFileSampleUsr.details_confirm_prompt + ' (y/N): '
+
 		t.expect(cp,'y')
+
 		for s in ('CHANGES','Removed','# zcash_','# foo','# bar','Added','# monero_'):
 			t.expect(s)
+
 		t.expect(cp,'n')
 
 		if old_set:
@@ -131,8 +134,6 @@ class TestSuiteCfg(TestSuiteBase):
 			t.expect('parsed chunks: 29')
 			t.expect('usr cfg: testnet=true rpc_password=passwOrd')
 
-		t.read()
-
 		if not old_set:
 			self.check_replaced_sample()
 

+ 1 - 1
test/test_py_d/ts_ethdev.py

@@ -1076,7 +1076,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 		t = self.spawn('mmgen-txcreate', self.eth_args + args)
 		for n in bals:
 			t.expect('[R]efresh balance:\b','R')
-			t.expect(' main menu): ',n)
+			t.expect(' main menu): ',n+'\n')
 			t.expect('Is this what you want? (y/N): ','y')
 		t.expect('[R]efresh balance:\b','q')
 		t.expect(f'Total unspent:.*\D{total}\D.*{total_coin}',regex=True)

+ 1 - 1
test/test_py_d/ts_input.py

@@ -158,7 +158,7 @@ class TestSuiteInput(TestSuiteBase):
 	def password_entry(self,prompt,cmd_args):
 		t = self.spawn('test/misc/password_entry.py',cmd_args,cmd_dir='.')
 		pw = 'abc-α'
-		t.expect(prompt,pw)
+		t.expect(prompt,pw+'\n')
 		ret = t.expect_getend('Entered: ')
 		assert ret == pw, f'Password mismatch! {ret} != {pw}'
 		return t

+ 4 - 4
test/test_py_d/ts_ref_3seed.py

@@ -108,8 +108,9 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared):
 
 	def ref_hincog_chk(self,desc='hidden incognito data'):
 		source = TestSuiteWalletConv.sources[str(self.seed_len)]
-		for wtype,edesc,of_arg in ('hic_wallet','',[]), \
-								('hic_wallet_old','(old format)',['-O']):
+		for wtype,edesc,of_arg in (
+				('hic_wallet',    '',            []),
+				('hic_wallet_old','(old format)',['-O']) ):
 			ic_arg = ['-H{},{}'.format(
 				joinpath(ref_dir,source[wtype]),
 				ref_wallet_incog_offset )
@@ -120,11 +121,10 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared):
 			t = self.spawn('mmgen-walletchk',
 				slarg + hparg + of_arg + ic_arg,
 				extra_desc=edesc)
-			t.passphrase(desc,self.wpasswd)
+			t.passphrase(desc,self.wpasswd+'\n')
 			if wtype == 'hic_wallet_old':
 				t.expect('Is the Seed ID correct? (Y/n): ','\n')
 			chk = t.expect_getend('Seed ID: ')
-			t.close()
 			cmp_or_die(self.seed_id,chk)
 			ok_msg()
 		t.skip_ok = True

+ 8 - 8
test/test_py_d/ts_regtest.py

@@ -1019,18 +1019,18 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 
 	def alice_txcreate_info(self,args=[]):
 		t = self.spawn('mmgen-txcreate',['--alice','-Bi'])
-		for d,s in (
-				( '\d+',                       'D'),
-				( '\d+',                       'D'),
-				( '\d+',                       'D'),
-				( pat_date,                    'w'),
-				( '\d+\s+\d+\s+'+pat_date_time,'q'),
-			):
+		pats = (
+			( '\d+',                       'D'),
+			( '\d+',                       'D'),
+			( '\d+',                       'D'),
+			( pat_date,                    'w'),
+			( '\d+\s+\d+\s+'+pat_date_time,'q'),
+		)
+		for d,s in pats:
 			t.expect(
 				r'\D{}\D.*\b{}\b'.format( rtAmts[0], d ),
 				s,
 				regex=True )
-		t.read()
 		return t
 
 	def stop(self):