Fix assert messaging on fields/exclude checking. Closes #833

This commit is contained in:
Tom Christie 2013-05-14 17:53:37 +01:00
parent d199a89c18
commit d62414147f

View File

@ -200,7 +200,7 @@ class BaseSerializer(WritableField):
# If 'fields' is specified, use those fields, in that order. # If 'fields' is specified, use those fields, in that order.
if self.opts.fields: if self.opts.fields:
assert isinstance(self.opts.fields, (list, tuple)), '`include` must be a list or tuple' assert isinstance(self.opts.fields, (list, tuple)), '`fields` must be a list or tuple'
new = SortedDict() new = SortedDict()
for key in self.opts.fields: for key in self.opts.fields:
new[key] = ret[key] new[key] = ret[key]
@ -208,7 +208,7 @@ class BaseSerializer(WritableField):
# Remove anything in 'exclude' # Remove anything in 'exclude'
if self.opts.exclude: if self.opts.exclude:
assert isinstance(self.opts.fields, (list, tuple)), '`exclude` must be a list or tuple' assert isinstance(self.opts.exclude, (list, tuple)), '`exclude` must be a list or tuple'
for key in self.opts.exclude: for key in self.opts.exclude:
ret.pop(key, None) ret.pop(key, None)