From 360d50a8d55761960d24a92af1059a091dc2301d Mon Sep 17 00:00:00 2001 From: Simeon Visser Date: Thu, 4 Oct 2018 12:21:51 +0100 Subject: [PATCH] Updated Inclusive to accept description as well This makes the implementation consistent with Exclusive which is also a subclass of Optional and which also accepts description --- voluptuous/schema_builder.py | 5 +++-- voluptuous/tests/tests.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/voluptuous/schema_builder.py b/voluptuous/schema_builder.py index 8d7a81a..8a18821 100644 --- a/voluptuous/schema_builder.py +++ b/voluptuous/schema_builder.py @@ -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 diff --git a/voluptuous/tests/tests.py b/voluptuous/tests/tests.py index fa44fbf..6464d37 100644 --- a/voluptuous/tests/tests.py +++ b/voluptuous/tests/tests.py @@ -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, @@ -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'