def main(): parser = ArgumentParser() parser.add_argument('filename', help='File to validate') parser.add_argument('-V', '--version', help='Version of the spec to validate against. Latest by default.', default=settings.DEFAULT_VERSION) args = parser.parse_args() try: validator = Validator(version=args.version) errors = validator.find_errors(args.filename) except exceptions.SchemaError as e: print(str(e), file=sys.stderr) sys.exit(1) if not errors: sys.exit(0) for error in errors: print('{path}: {msg}'.format(path=' > '.join([str(item) for item in error.path]), msg=error.message)) sys.exit(1)
def test_find_errors_fails(self): v = Validator() with pytest.raises(exceptions.SchemaError) as e: v.find_errors('foo/bar/baz/') assert 'No such file' in str(e)
def test_find_errors(self): v = Validator() v.find_errors(helper_test.get_fixture('valid_spec.yaml'))