Browse Source

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

MMGen 5 years ago
parent
commit
e81b4094e3
3 changed files with 27 additions and 24 deletions
  1. 26 0
      test/common.py
  2. 0 23
      test/test_py_d/common.py
  3. 1 1
      test/test_py_d/ts_autosign.py

+ 26 - 0
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)

+ 0 - 23
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'
 

+ 1 - 1
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 *