def string_or_dict(_object, *args): """Validator - Must be Basestring or Dictionary""" error_msg = 'not of type dictionary or string' if isinstance(_object, six.string_types): return if isinstance(_object, dict): return raise exceptions.Invalid('dict or basestring type', pair='value', msg=None, reason=error_msg, *args)
def test_full_message_for_callable_with_value(self): error = exceptions.Invalid(foo, ['foo', 'bar', 'baz'], pair='value') result = error.__str__() assert "-> foo -> bar -> baz did not pass validation against callable: foo" == result
def test_full_message_for_value(self): error = exceptions.Invalid('3', ['foo', 'bar', 'baz'], pair='value') result = error.__str__() assert "-> foo -> bar -> baz did not match '3'" == result
def test_full_message(self): error = exceptions.Invalid('3', ['foo', 'bar', 'baz']) result = error.__str__() assert "-> foo -> bar -> baz key did not match '3'" == result
def test_multiple_keys_in_format_path(self): error = exceptions.Invalid('schema', ['key', 'subkey', 'bar']) assert '-> key -> subkey -> bar' in error._format_path()
def test_include_the_key_in_str(self): error = exceptions.Invalid('key', ['path']) assert 'key' in error.__str__()
def test_include_the_key(self): error = exceptions.Invalid('key', ['foo', 'bar', 'key']) assert 'key' in error._format_path()