How to use catcher - 10 common examples

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 / test / __init__.py View on Github external
from os.path import join

from catcher.utils.module_utils import load_external_actions

TEST_DIR = 'test/tmp'

load_external_actions('catcher.steps')


def get_test_dir(testcase: str) -> str:
    return join(TEST_DIR, testcase)
github comtihon / catcher / catcher / utils / external_utils.py View on Github external
def _compile_java(file, variables, libraries=None):
    resource_dir = variables['RESOURCES_DIR']
    classpath = _form_classpath(libraries)
    return_code, stdout, stderr = run_cmd('javac {} -d . *.java'.format(classpath),
                                          variables,
                                          cwd=resource_dir,
                                          shell=True)  # compile everything
    if return_code != 0:
        raise Exception("Can't compile {}. Out: {}, Err: {}".format(file, stdout, stderr))
    class_file = file_utils.find_resource(resource_dir, file_utils.get_filename(file), '.class')
    if len(class_file) > 1:
        debug('Found more than 1 resource for {}: {}. Use last.'.format(file_utils.get_filename(file), class_file))
        class_file = class_file[-1]
    else:
        class_file = class_file[0]
    module = file_utils.cut_part_path(resource_dir, class_file).replace('/', '.')
    return module.split('.class')[0]
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 / core / runner.py View on Github external
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 / 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 / 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 / core / runner.py View on Github external
def prepare_test(self, file: str, variables: dict, override_vars: None or dict = None) -> Runnable:
        body = read_source_file(file)
        registered_includes = self.process_includes(file, body.get('include', []), variables)
        variables = self._compose_variables(body.get('variables', {}), variables, override_vars)
        ignore = body.get('ignore', False)
        if ignore:
            if not isinstance(ignore, bool):
                ignore = Operator.find_operator(ignore).operation(variables)
            if ignore:
                return IgnoredTest(path=self.path, variables=deepcopy(variables))
        return Test(self.path,
                    includes=registered_includes,
                    variables=deepcopy(variables),  # each test has independent variables
                    config=body.get('config', {}),
                    steps=body.get('steps', []),
                    final=body.get('finally', []),
                    modules=self.modules,
                    override_vars=self.environment)
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 / __main__.py View on Github external
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)
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