move some functions from 'test/test_py_d/common.py' to 'test/common.py'

This commit is contained in:
The MMGen Project 2019-06-06 10:33:17 +00:00
commit e81b4094e3
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 27 additions and 24 deletions

View file

@ -136,3 +136,29 @@ def init_coverage():
try: os.mkdir(coverdir,0o755)
except: pass
return coverdir,acc_file
devnull_fh = open(('/dev/null','null.out')[g.platform == 'win'],'w')
def silence():
if not (opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output)):
g.stdout = g.stderr = devnull_fh
def end_silence():
if not (opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output)):
g.stdout = sys.stdout
g.stderr = sys.stderr
def omsg(s):
sys.stderr.write(s + '\n')
def omsg_r(s):
sys.stderr.write(s)
sys.stderr.flush()
def imsg(s):
if opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output):
omsg(s)
def imsg_r(s):
if opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output):
omsg_r(s)
def iqmsg(s):
if not opt.quiet: omsg(s)
def iqmsg_r(s):
if not opt.quiet: omsg_r(s)

View file

@ -80,29 +80,6 @@ def confirm_continue():
else:
raise KeyboardInterrupt('Exiting at user request')
def omsg(s):
sys.stderr.write(s + '\n')
def omsg_r(s):
sys.stderr.write(s)
def imsg(s):
if opt.exact_output or opt.verbose: omsg(s)
def imsg_r(s):
if opt.exact_output or opt.verbose: omsg_r(s)
def iqmsg(s):
if not opt.quiet: omsg(s)
def iqmsg_r(s):
if not opt.quiet: omsg_r(s)
devnull_fh = open(('/dev/null','null.out')[g.platform == 'win'],'w')
def silence():
if not (opt.verbose or opt.exact_output):
g.stdout = g.stderr = devnull_fh
def end_silence():
if not (opt.verbose or opt.exact_output):
g.stdout = sys.stdout
g.stderr = sys.stderr
def randbool():
return os.urandom(1).hex()[0] in '02468ace'

View file

@ -23,7 +23,7 @@ ts_autosign.py: Autosign tests for the test.py test suite
import os,shutil
from mmgen.globalvars import g
from mmgen.opts import opt
from test.common import read_from_file
from test.common import *
from test.test_py_d.common import *
from test.test_py_d.ts_base import *