Skip to content

Commit

Permalink
check field None
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Oct 8, 2023
1 parent d49850f commit 7b94081
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/plone/restapi/tests/test_dxfield_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ def setUp(self):
]

def serialize(self, fieldname, value):
field = None
for schema in iterSchemata(self.doc1):
if fieldname in schema:
field = schema.get(fieldname)
break
dm = getMultiAdapter((self.doc1, field), IDataManager)
dm.set(value)
serializer = getMultiAdapter((field, self.doc1, self.request), IFieldSerializer)
return serializer()
if field is not None:
dm = getMultiAdapter((self.doc1, field), IDataManager)
dm.set(value)
serializer = getMultiAdapter((field, self.doc1, self.request), IFieldSerializer)
return serializer()

return None

def test_ascii_field_serialization_returns_unicode(self):
value = self.serialize("test_ascii_field", "foo")
Expand Down

0 comments on commit 7b94081

Please sign in to comment.