Skip to content

Commit f191c08

Browse files
Maiky Guanaesfgmacedo
authored andcommitted
chore(schematics) Improves ChoicesEnumType to receive kwargs
1 parent 6342b6e commit f191c08

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

choicesenum/schematics/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77

88
class ChoicesEnumType(BaseType):
9-
def __init__(self, type_):
9+
def __init__(self, type_, **kwargs):
1010
if not issubclass(type_, ChoicesEnum):
1111
raise ValidationError(self.Messages.INVALID_TYPE)
12-
super(ChoicesEnumType, self).__init__(type_)
12+
super(ChoicesEnumType, self).__init__(type_, kwargs)
1313
self.type = type_
1414

1515
def to_native(self, value, context=None):

tests/test_schematics_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def test_choices_enum_type(http_statuses):
1212
assert state.to_primitive(200) == http_statuses.OK.value
1313

1414

15+
def test_choices_enum_type_with_extra_params(http_statuses):
16+
state = ChoicesEnumType(http_statuses, required=True)
17+
assert state.to_native(200) is http_statuses.OK
18+
19+
1520
def test_choices_enum_type_should_throw_exception():
1621
with pytest.raises(ValidationError) as e:
1722
ChoicesEnumType(object)

0 commit comments

Comments
 (0)