Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(args=None):
try:
arguments = docopt(__doc__, argv=args, version=APPVSN)
except DocoptExit as usage:
print(usage)
sys.exit(1)
path = os.getcwd()
logger.configure(arguments['--log-level'], not arguments['--no-color'])
result = run_tests(path, arguments)
if result:
sys.exit(0)
else:
sys.exit(1)
def _run_finally(cls, test, file, result: bool):
if test and test.final:
logger.log_storage.test_start(file, test_type='{}_cleanup'.format(file))
try:
test.run_finally(result)
info('Test ' + file + ' [cleanup] ' + logger.green(' passed.'))
logger.log_storage.test_end(file, True, test_type='{} [cleanup]'.format(file))
except Exception as e:
warning('Test ' + file + ' [cleanup] ' + logger.red(' failed: ') + str(e))
debug(traceback.format_exc())
logger.log_storage.test_end(file, False, test_type='{} [cleanup]'.format(file))
ok = len([t for t in tests if t['status'] == 'OK' and t['comment'] != 'Skipped'])
skipped = len([t for t in tests if t['comment'] == 'Skipped'])
fail = len(tests) - (ok + skipped)
percent = (ok + skipped) / len(tests) * 100 if len(tests) > 0 else 0
out_string = 'Test run {}.'.format(logger.blue(str(len(tests))))
out_string += ' Success: ' + logger.green(str(ok)) + ', Fail: '
if fail > 0:
out_string += logger.red(str(fail))
else:
out_string += logger.green(str(fail))
if skipped:
out_string += ', Skipped: ' + logger.yellow(str(skipped))
out_string += '. Total: '
fun = logger.red
if percent >= 100:
fun = logger.green
elif percent >= 66:
fun = logger.light_green
elif percent >= 33:
fun = logger.yellow
out_string += fun('{:.0f}%'.format(percent))
return out_string
fail = len(tests) - (ok + skipped)
percent = (ok + skipped) / len(tests) * 100 if len(tests) > 0 else 0
out_string = 'Test run {}.'.format(logger.blue(str(len(tests))))
out_string += ' Success: ' + logger.green(str(ok)) + ', Fail: '
if fail > 0:
out_string += logger.red(str(fail))
else:
out_string += logger.green(str(fail))
if skipped:
out_string += ', Skipped: ' + logger.yellow(str(skipped))
out_string += '. Total: '
fun = logger.red
if percent >= 100:
fun = logger.green
elif percent >= 66:
fun = logger.light_green
elif percent >= 33:
fun = logger.yellow
out_string += fun('{:.0f}%'.format(percent))
return out_string