From e81b4094e3e024bb44203f9c9a9e9928ee5d10d8 Mon Sep 17 00:00:00 2001 From: MMGen Date: Thu, 6 Jun 2019 10:33:17 +0000 Subject: [PATCH] move some functions from 'test/test_py_d/common.py' to 'test/common.py' --- test/common.py | 26 ++++++++++++++++++++++++++ test/test_py_d/common.py | 23 ----------------------- test/test_py_d/ts_autosign.py | 2 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/test/common.py b/test/common.py index 64d27c68..6b688249 100755 --- a/test/common.py +++ b/test/common.py @@ -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) diff --git a/test/test_py_d/common.py b/test/test_py_d/common.py index 5ea6a401..025d69b7 100755 --- a/test/test_py_d/common.py +++ b/test/test_py_d/common.py @@ -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' diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index fe718fd6..6f365711 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -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 *