|
@@ -57,6 +57,25 @@ start_time = int(time.time())
|
|
|
if opt.list:
|
|
|
Die(0,' '.join(all_tests))
|
|
|
|
|
|
+class UnitTestHelpers(object):
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def process_bad_data(cls,data):
|
|
|
+ desc_w = max(len(e[0]) for e in data)
|
|
|
+ exc_w = max(len(e[1]) for e in data)
|
|
|
+ for (desc,exc_chk,emsg_chk,func) in data:
|
|
|
+ try:
|
|
|
+ vmsg_r(' {:{w}}'.format(desc+':',w=desc_w+1))
|
|
|
+ func()
|
|
|
+ except Exception as e:
|
|
|
+ exc = type(e).__name__
|
|
|
+ emsg = e.args[0]
|
|
|
+ vmsg(' {:{w}} [{}]'.format(exc,emsg,w=exc_w))
|
|
|
+ assert exc == exc_chk,'{!r}: incorrect exception type (expected {!r})'.format(exc,exc_chk)
|
|
|
+ assert emsg_chk in emsg,'{!r}: incorrect error msg (should contain {!r}'.format(emsg,emsg_chk)
|
|
|
+ else:
|
|
|
+ rdie(3,"\nillegal action '{}' failed to raise exception {!r}".format(desc,exc_chk))
|
|
|
+
|
|
|
try:
|
|
|
for test in cmd_args:
|
|
|
if test not in all_tests:
|
|
@@ -67,7 +86,7 @@ try:
|
|
|
modname = 'test.unit_tests_d.ut_{}'.format(test)
|
|
|
mod = importlib.import_module(modname)
|
|
|
gmsg('Running unit test {}'.format(test))
|
|
|
- if not mod.unit_test().run_test(test):
|
|
|
+ if not mod.unit_test().run_test(test,UnitTestHelpers):
|
|
|
rdie(1,'Unit test {!r} failed'.format(test))
|
|
|
del mod
|
|
|
|