How to use the catcher.utils.file_utils.read_source_file 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 / parser.py View on Github external
def read_test(self, test_file: str):
        body = read_source_file(test_file)
        return Test(self.path,
                    test_file,
                    includes=body.get('include', []),
                    variables=body.get('variables', {}),
                    config=body.get('config', {}),
                    steps=body.get('steps', []),
                    final=body.get('finally', []),
                    ignore=body.get('ignore', False))
github comtihon / catcher / catcher / core / runner.py View on Github external
def run_tests(self) -> bool:
        try:
            self._compose.up()
            if self.system_vars:
                debug('Use system variables: ' + str(list(self.system_vars.keys())))
                variables = self.system_vars
            else:
                variables = {}
            if self.inventory is not None:
                inv_vars = read_source_file(self.inventory)
                inv_vars['INVENTORY'] = get_filename(self.inventory)
                inv_vars['INVENTORY_FILE'] = self.inventory
                variables = try_get_object(fill_template_str(inv_vars, variables))  # fill env vars
            variables['CURRENT_DIR'] = self.path
            variables['RESOURCES_DIR'] = self.resources or self.path + '/resources'
            test_files = get_files(self.tests_path)
            results = []
            for file in test_files:
                self.all_includes = None  # each test has it's own include tree
                variables['TEST_NAME'] = file
                test, result = self._run_test(file, variables)
                results.append(result)
                self._run_finally(test, file, result)
            return all(results)
        finally:
            logger.log_storage.write_report(join(self.path, 'reports'))
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 / parser.py View on Github external
def read_inventory(self) -> dict:
        if self.inventory is not None:
            inv_vars = read_source_file(self.inventory)
            inv_vars['INVENTORY'] = get_filename(self.inventory)
            inv_vars['INVENTORY_FILE'] = self.inventory
            return inv_vars
        return {}