more coverage
This commit is contained in:
@@ -11,7 +11,7 @@ class GroupedModelChoiceIterator(ModelChoiceIterator):
|
||||
super().__init__(field)
|
||||
|
||||
def __iter__(self):
|
||||
if self.field.empty_label is not None:
|
||||
if self.field.empty_label is not None: # pragma: no cover
|
||||
yield ("", self.field.empty_label)
|
||||
queryset = self.queryset
|
||||
# Can't use iterator() when queryset uses prefetch_related()
|
||||
@@ -25,7 +25,7 @@ class GroupedModelChoiceField(ModelChoiceField):
|
||||
def __init__(self, *args, choices_groupby, **kwargs):
|
||||
if isinstance(choices_groupby, str):
|
||||
choices_groupby = attrgetter(choices_groupby)
|
||||
elif not callable(choices_groupby):
|
||||
elif not callable(choices_groupby): # pragma: no cover
|
||||
raise TypeError('choices_groupby must either be a str or a callable accepting a single argument')
|
||||
self.iterator = partial(GroupedModelChoiceIterator, groupby=choices_groupby)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user