Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def action(self, includes: dict, variables: dict) -> tuple:
if self.source_file: # read from file
resources = variables['RESOURCES_DIR']
out = fill_template_str(read_file(os.path.join(resources, self.source_file)), variables)
else:
out = fill_template(self.source, variables)
if self.dst is None:
info(out)
else:
dst = fill_template(self.dst, variables)
with open(join(self.path, dst), 'w') as f:
f.write(str(out))
return variables, out
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)
def action(self, includes: dict, variables: dict) -> dict:
filled_vars = dict([(k, fill_template_str(v, variables)) for (k, v) in self.variables.items()])
out = fill_template_str(self.include, variables)
test, tag = get_tag(out)
if test not in includes:
error('No include registered for name ' + test)
raise Exception('No include registered for name ' + test)
include = includes[test]
variables = merge_two_dicts(include.variables, merge_two_dicts(variables, filled_vars))
include.variables = try_get_object(fill_template_str(variables, variables))
try:
info('Running {}.{}'.format(test, '' if tag is None else tag))
logger.log_storage.nested_test_in()
variables = include.run(tag=tag, raise_stop=True)
logger.log_storage.nested_test_out()
except SkipException:
logger.log_storage.nested_test_out()
debug('Include ignored')
return variables
except StopException as e:
logger.log_storage.nested_test_out()
raise e
except Exception as e:
logger.log_storage.nested_test_out()
if not self.ignore_errors:
raise Exception('Step run ' + test + ' failed: ' + str(e))
return variables