def test_check_and(): check = check_and(check_type(str), check_regex) with pytest.raises(ValidationError) as excinfo: check(True) assert excinfo.value.error_msg == 'Expected str got bool' with pytest.raises(ValidationError) as excinfo: check(str('(')) assert excinfo.value.error_msg == "'(' is not a valid python regex"
def _make_argparser(filenames_help): parser = argparse.ArgumentParser() parser.add_argument('filenames', nargs='*', help=filenames_help) parser.add_argument('-V', '--version', action='version', version=C.VERSION) return parser MANIFEST_HOOK_DICT = schema.Map( 'Hook', 'id', schema.Required('id', schema.check_string), schema.Required('name', schema.check_string), schema.Required('entry', schema.check_string), schema.Required( 'language', schema.check_and(schema.check_string, check_language), ), schema.Conditional( 'files', schema.check_and(schema.check_string, schema.check_regex), condition_key='always_run', condition_value=False, ensure_absent=True, ), schema.Optional( 'additional_dependencies', schema.check_array(schema.check_string), [], ), schema.Optional('args', schema.check_array(schema.check_string), []), schema.Optional('always_run', schema.check_bool, False),
def _make_argparser(filenames_help): parser = argparse.ArgumentParser() parser.add_argument('filenames', nargs='*', help=filenames_help) parser.add_argument('-V', '--version', action='version', version=C.VERSION) return parser MANIFEST_HOOK_DICT = schema.Map( 'Hook', 'id', schema.Required('id', schema.check_string), schema.Required('name', schema.check_string), schema.Required('entry', schema.check_string), schema.Required( 'language', schema.check_and(schema.check_string, check_language), ), schema.Conditional( 'files', schema.check_and(schema.check_string, schema.check_regex), condition_key='always_run', condition_value=False, ), schema.Optional( 'additional_dependencies', schema.check_array(schema.check_string), [], ), schema.Optional('args', schema.check_array(schema.check_string), []), schema.Optional('always_run', schema.check_bool, False), schema.Optional('description', schema.check_string, ''), schema.Optional( 'exclude',
def test_check_and_ok(): check = check_and(check_type(str), check_regex) check(str('^$'))
def _make_argparser(filenames_help): parser = argparse.ArgumentParser() parser.add_argument('filenames', nargs='*', help=filenames_help) parser.add_argument('-V', '--version', action='version', version=C.VERSION) return parser MANIFEST_HOOK_DICT = schema.Map( 'Hook', 'id', schema.Required('id', schema.check_string), schema.Required('name', schema.check_string), schema.Required('entry', schema.check_string), schema.Required( 'language', schema.check_and(schema.check_string, check_language), ), schema.Conditional( 'files', schema.check_and(schema.check_string, schema.check_regex), condition_key='always_run', condition_value=False, ), schema.Optional( 'additional_dependencies', schema.check_array(schema.check_string), [], ), schema.Optional('args', schema.check_array(schema.check_string), []), schema.Optional('always_run', schema.check_bool, False), schema.Optional('pass_filenames', schema.check_bool, True), schema.Optional('description', schema.check_string, ''), schema.Optional(