How to use the catcher.utils.logger.green function in catcher

To help you get started, we’ve selected a few catcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github comtihon / catcher / catcher / core / runner.py View on Github external
def _run_test(self, file, variables):
        test = None
        try:
            test = self.prepare_test(file, variables)
            logger.log_storage.test_start(file)
            test.run()
            info('Test ' + file + logger.green(' passed.'))
            logger.log_storage.test_end(file, True)
            return test, True
        except SkipException:
            info('Test ' + file + logger.yellow(' skipped.'))
            logger.log_storage.test_end(file, True, end_comment='Skipped')
            return test, True
        except Exception as e:
            warning('Test ' + file + logger.red(' failed: ') + str(e))
            debug(traceback.format_exc())
            logger.log_storage.test_end(file, False, str(e))
            return test, False
github comtihon / catcher / catcher / modules / log_storage.py View on Github external
def print_summary(self, path):
        from catcher.utils import logger
        tests = [t for t in self._data if t.get('type') == 'test']
        out_string = self.calculate_statistics(tests)
        for test in tests:
            out_string += '\nTest {}: '.format(file_utils.cut_path(path, test['file']))
            # select only step's ends, which belongs to the current test (excluding registered includes run)
            step_finish_only = [o for o in test['output'] if 'success' in o and o['nested'] == 0]
            if test['status'] == 'OK' and test['comment'] != 'Skipped':
                out_string += logger.green('pass')
            elif test['comment'] == 'Skipped':
                out_string += logger.yellow('skipped')
            else:
                out_string += logger.red('fail') + ', on step {}'.format(len(step_finish_only))
        logger.info(out_string)
github comtihon / catcher / catcher / modules / log_storage.py View on Github external
def calculate_statistics(tests):
        from catcher.utils import logger
        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
github comtihon / catcher / catcher / core / runner.py View on Github external
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))
github comtihon / catcher / catcher / modules / log_storage.py View on Github external
def calculate_statistics(tests):
        from catcher.utils import logger
        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