Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
IsDir,
IsFile,
Length,
LengthInvalid,
Literal,
LiteralInvalid,
Marker,
Expand Down Expand Up @@ -870,8 +871,10 @@ def test_length_too_long():
def test_length_invalid():
v = None
s = Schema(Length(min=0, max=2))
with pytest.raises(MultipleInvalid):
with pytest.raises(MultipleInvalid) as ctx:
s(v)
# a value with no length must be reported as a LengthInvalid, not a RangeInvalid
assert isinstance(ctx.value.errors[0], LengthInvalid)


def test_equal():
Expand Down
2 changes: 1 addition & 1 deletion voluptuous/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ def __call__(self, v):

# Objects that have no length e.g. None or strings will raise TypeError
except TypeError:
raise RangeInvalid(self.msg or 'invalid value or type')
raise LengthInvalid(self.msg or 'invalid value or type')

def __repr__(self):
return 'Length(min=%s, max=%s)' % (self.min, self.max)
Expand Down
Loading