Minor improvements to test framework

Show correct module for test
Print error output
This commit is contained in:
RunasSudo 2017-11-24 19:38:13 +11:00
parent 6af132bb5f
commit 529166867f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -51,7 +51,13 @@ class BaseJSTestCase(TestCase):
def add_method(cls, method): def add_method(cls, method):
def call_method(self, *args): def call_method(self, *args):
# TODO: args # TODO: args
return cls.ctx.eval('test.' + method + '()') try:
return cls.ctx.eval('test.' + method + '()')
except execjs._exceptions.ProcessExitedWithNonZeroStatus as ex:
import traceback
traceback.print_exc()
print(ex.stderr)
self.fail()
setattr(cls, method, call_method) setattr(cls, method, call_method)
# Test discovery # Test discovery
@ -74,8 +80,8 @@ def run_tests(prefix=None, lang=None):
continue continue
impl = obj() impl = obj()
cls_py = type(name + 'ImplPy', (BasePyTestCase,), {'impl': impl}) cls_py = type(name + 'ImplPy', (BasePyTestCase,), {'__module__': module_name, 'impl': impl})
cls_js = type(name + 'ImplJS', (BaseJSTestCase,), {'module': module_name, 'name': name}) cls_js = type(name + 'ImplJS', (BaseJSTestCase,), {'__module__': module_name, 'module': module_name, 'name': name})
for method in dir(impl): for method in dir(impl):
method_val = getattr(impl, method) method_val = getattr(impl, method)
if isinstance(method_val, types.MethodType) and not hasattr(cls_py, method): if isinstance(method_val, types.MethodType) and not hasattr(cls_py, method):