Browse Source

test suite: minor changes

MMGen 5 years ago
parent
commit
18ee26f851
4 changed files with 13 additions and 12 deletions
  1. 1 0
      test/common.py
  2. 1 1
      test/pexpect.py
  3. 1 1
      test/scrambletest.py
  4. 10 10
      test/test_py_d/ts_shared.py

+ 1 - 0
test/common.py

@@ -25,6 +25,7 @@ class TestSuiteFatalException(Exception): pass
 
 import os
 from mmgen.common import *
+from mmgen.devtools import *
 
 ascii_uc   = ''.join(map(chr,list(range(65,91))))   # 26 chars
 ascii_lc   = ''.join(map(chr,list(range(97,123))))  # 26 chars

+ 1 - 1
test/pexpect.py

@@ -24,7 +24,7 @@ import sys,os,time
 from mmgen.globalvars import g
 from mmgen.opts import opt
 from mmgen.util import msg,msg_r,vmsg,vmsg_r,rmsg,red,yellow,green,cyan,die,rdie
-from test.common import getrandstr
+from test.common import *
 
 try:
 	import pexpect

+ 1 - 1
test/scrambletest.py

@@ -28,7 +28,7 @@ os.environ['MMGEN_TEST_SUITE'] = '1'
 
 # Import this _after_ local path's been added to sys.path
 from mmgen.common import *
-from test.common import init_coverage
+from test.common import *
 
 opts_data = {
 	'text': {

+ 10 - 10
test/test_py_d/ts_shared.py

@@ -188,13 +188,15 @@ class TestSuiteShared(object):
 		if sid: cmp_or_die(chk,sid)
 		return t
 
-	def addrgen(self,wf,pf=None,check_ref=False,ftype='addr',id_str=None,extra_args=[],mmtype=None):
-		if not mmtype and ftype[:4] != 'pass':
+	def addrgen(self,wf,pf=None,check_ref=False,ftype='addr',id_str=None,extra_args=[],mmtype=None,stdout=False):
+		passgen = ftype[:4] == 'pass'
+		if not mmtype and not passgen:
 			mmtype = self.segwit_mmtype
-		cmd_pfx = (ftype,'pass')[ftype[:4]=='pass']
+		cmd_pfx = (ftype,'pass')[passgen]
 		t = self.spawn('mmgen-{}gen'.format(cmd_pfx),
 				['-d',self.tmpdir] + extra_args +
 				([],['--type='+str(mmtype)])[bool(mmtype)] +
+				([],['--stdout'])[stdout] +
 				([],[wf])[bool(wf)] +
 				([],[id_str])[bool(id_str)] +
 				[getattr(self,'{}_idx_list'.format(cmd_pfx))],
@@ -202,15 +204,13 @@ class TestSuiteShared(object):
 		t.license()
 		t.passphrase('MMGen wallet',self.wpasswd)
 		t.expect('Passphrase is OK')
-		desc = ('address','password')[ftype[:4]=='pass']
+		desc = ('address','password')[passgen]
 		chk = t.expect_getend(r'Checksum for {} data .*?: '.format(desc),regex=True)
-		if ftype[:4] == 'pass':
-			t.expect('Encrypt password list? (y/N): ','\n')
-			t.written_to_file('Password list',oo=True)
-		else:
-			t.written_to_file('Addresses',oo=True)
+		if passgen:
+			t.expect('Encrypt password list? (y/N): ','N')
+		t.read() if stdout else t.written_to_file(('Addresses','Password list')[passgen])
 		if check_ref:
-			chk_ref = (self.chk_data[self.test_name] if ftype[:4] == 'pass' else
+			chk_ref = (self.chk_data[self.test_name] if passgen else
 						self.chk_data[self.test_name][self.fork][g.testnet])
 			cmp_or_die(chk,chk_ref,desc='{}list data checksum'.format(ftype))
 		return t