Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Treat Python 2 old-style classes like types when validating.
- [324](https://github.com/alecthomas/voluptuous/pull/324):
Default values MUST now pass validation just as any regular value. This is a backward incompatible change if a schema uses default values that don't pass validation against the specified schema.
- [328](https://github.com/alecthomas/voluptuous/pull/328):
Modified __lt__ in Marker class to allow comparison with non Marker objects, such as str and int

## [0.10.5]

Expand Down
4 changes: 3 additions & 1 deletion voluptuous/schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,9 @@ def __repr__(self):
return repr(self.schema)

def __lt__(self, other):
return self.schema < other.schema
if isinstance(other, Marker):
return self.schema < other.schema
return self.schema < other

def __hash__(self):
return hash(self.schema)
Expand Down
5 changes: 5 additions & 0 deletions voluptuous/tests/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,8 @@ Ensure that subclasses of Invalid of are raised as is.
... exc = e
>>> exc.errors[0].__class__.__name__
'SpecialInvalid'

Ensure that Optional('Classification') < 'Name' will return True instead of throwing an AttributeError

>>> Optional('Classification') < 'Name'
True
4 changes: 4 additions & 0 deletions voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,3 +1137,7 @@ def test_self_all():
def test_SomeOf_on_bounds_assertion():
with raises(AssertionError, 'when using "SomeOf" you should specify at least one of min_valid and max_valid'):
SomeOf(validators=[])


def test_comparing_voluptuous_object_to_str():
assert_true(Optional('Classification') < 'Name')