Skip to content

Commit

Permalink
Updated Inclusive to accept description as well
Browse files Browse the repository at this point in the history
This makes the implementation consistent with Exclusive which is also a subclass of Optional and which also accepts description
  • Loading branch information
svisser committed Oct 4, 2018
1 parent e72fd3b commit 360d50a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions voluptuous/schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,8 +1121,9 @@ class Inclusive(Optional):
True
"""

def __init__(self, schema, group_of_inclusion, msg=None):
super(Inclusive, self).__init__(schema, msg=msg)
def __init__(self, schema, group_of_inclusion, msg=None, description=None):
super(Inclusive, self).__init__(schema, msg=msg,
description=description)
self.group_of_inclusion = group_of_inclusion


Expand Down
7 changes: 5 additions & 2 deletions voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from nose.tools import assert_equal, assert_false, assert_raises, assert_true

from voluptuous import (
Schema, Required, Exclusive, Optional, Extra, Invalid, In, Remove, Literal,
Url, MultipleInvalid, LiteralInvalid, TypeInvalid, NotIn, Match, Email,
Schema, Required, Exclusive, Inclusive, Optional, Extra, Invalid, In, Remove,
Literal, Url, MultipleInvalid, LiteralInvalid, TypeInvalid, NotIn, Match, Email,
Replace, Range, Coerce, All, Any, Length, FqdnUrl, ALLOW_EXTRA, PREVENT_EXTRA,
validate, ExactSequence, Equal, Unordered, Number, Maybe, Datetime, Date,
Contains, Marker, IsDir, IsFile, PathExists, SomeOf, TooManyValid, Self,
Expand Down Expand Up @@ -1035,6 +1035,9 @@ def test_description():
exclusive = Exclusive('alpha', 'angles', description='Hello')
assert exclusive.description == 'Hello'

inclusive = Inclusive('alpha', 'angles', description='Hello')
assert inclusive.description == 'Hello'

required = Required('key', description='Hello')
assert required.description == 'Hello'

Expand Down

0 comments on commit 360d50a

Please sign in to comment.