示例#1
0
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"
示例#2
0
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"
示例#3
0
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),
示例#4
0
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',
示例#5
0
def test_check_and_ok():
    check = check_and(check_type(str), check_regex)
    check(str('^$'))
示例#6
0
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(
示例#7
0
def test_check_and_ok():
    check = check_and(check_type(str), check_regex)
    check(str('^$'))