Browse Source

unit_tests.py.process_bad_data(): support coroutines

The MMGen Project 8 months ago
parent
commit
0d3086fc61
1 changed files with 6 additions and 4 deletions
  1. 6 4
      test/unit_tests.py

+ 6 - 4
test/unit_tests.py

@@ -20,7 +20,7 @@
 test/unit_tests.py: Unit tests for the MMGen suite
 test/unit_tests.py: Unit tests for the MMGen suite
 """
 """
 
 
-import sys,os,time,importlib,platform
+import sys,os,time,importlib,platform,asyncio
 
 
 try:
 try:
 	from include.test_init import repo_root
 	from include.test_init import repo_root
@@ -35,7 +35,7 @@ if not os.getenv('MMGEN_DEVTOOLS'):
 
 
 from mmgen.cfg import Config,gc
 from mmgen.cfg import Config,gc
 from mmgen.color import green,gray,brown,orange
 from mmgen.color import green,gray,brown,orange
-from mmgen.util import msg,gmsg,ymsg,Msg,async_run
+from mmgen.util import msg,gmsg,ymsg,Msg
 
 
 from test.include.common import set_globals,end_msg
 from test.include.common import set_globals,end_msg
 
 
@@ -130,7 +130,9 @@ class UnitTestHelpers:
 		for (desc,exc_chk,emsg_chk,func) in data:
 		for (desc,exc_chk,emsg_chk,func) in data:
 			try:
 			try:
 				cfg._util.vmsg_r('  {}{:{w}}'.format(pfx, desc+':', w=desc_w+1))
 				cfg._util.vmsg_r('  {}{:{w}}'.format(pfx, desc+':', w=desc_w+1))
-				func()
+				ret = func()
+				if type(ret).__name__ == 'coroutine':
+					asyncio.run(ret)
 			except Exception as e:
 			except Exception as e:
 				exc = type(e).__name__
 				exc = type(e).__name__
 				emsg = e.args[0]
 				emsg = e.args[0]
@@ -158,7 +160,7 @@ def run_test(test,subtest=None):
 		try:
 		try:
 			ret = getattr(t,subtest.replace('-','_'))(test,UnitTestHelpers(subtest))
 			ret = getattr(t,subtest.replace('-','_'))(test,UnitTestHelpers(subtest))
 			if type(ret).__name__ == 'coroutine':
 			if type(ret).__name__ == 'coroutine':
-				ret = async_run(ret)
+				ret = asyncio.run(ret)
 		except:
 		except:
 			if getattr(t,'silence_output',False):
 			if getattr(t,'silence_output',False):
 				t._end_silence()
 				t._end_silence()