def test__error_3(): valids = [ { 'type': 'string', 'regex': '0x[0-9a-f]{2}' }, { 'type': 'integer', 'min': 0, 'max': 255 }, ] v = Validator(schema={'foo': {'oneof': valids}}) v.document = {'foo': '0x100'} v._error('foo', errors.ONEOF, (), 0, 2) error = v._errors[0] assert error.document_path == ('foo', ) assert error.schema_path == ('foo', 'oneof') assert error.code == 0x92 assert error.rule == 'oneof' assert error.constraint == valids assert error.value == '0x100' assert error.info == ((), 0, 2) assert error.is_group_error assert error.is_logic_error
def test__error_1(): v = Validator(schema={'foo': {'type': 'string'}}) v.document = {'foo': 42} v._error('foo', errors.BAD_TYPE, 'string') error = v._errors[0] assert error.document_path == ('foo', ) assert error.schema_path == ('foo', 'type') assert error.code == 0x24 assert error.rule == 'type' assert error.constraint == 'string' assert error.value == 42 assert error.info == ('string', ) assert not error.is_group_error assert not error.is_logic_error
def test__error_2(): v = Validator(schema={'foo': {'keysrules': {'type': 'integer'}}}) v.document = {'foo': {'0': 'bar'}} v._error('foo', errors.KEYSRULES, ()) error = v._errors[0] assert error.document_path == ('foo', ) assert error.schema_path == ('foo', 'keysrules') assert error.code == 0x83 assert error.rule == 'keysrules' assert error.constraint == {'type': 'integer'} assert error.value == {'0': 'bar'} assert error.info == ((), ) assert error.is_group_error assert not error.is_logic_error