From 7b94081a41859c3eb720d12a44b4d6b4a1a77f8b Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Sun, 8 Oct 2023 09:14:03 +0200 Subject: [PATCH] check field None --- src/plone/restapi/tests/test_dxfield_serializer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plone/restapi/tests/test_dxfield_serializer.py b/src/plone/restapi/tests/test_dxfield_serializer.py index 288992b8fb..3965aceaee 100644 --- a/src/plone/restapi/tests/test_dxfield_serializer.py +++ b/src/plone/restapi/tests/test_dxfield_serializer.py @@ -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")