From b034f5d196e9cf01bcd9908081a5182b5735e27e Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 6 May 2022 20:10:33 -0700 Subject: [PATCH] Fixed broken test by implementing FieldDescriptor.has_presence. PiperOrigin-RevId: 447124542 --- python/descriptor.c | 8 ++++++++ python/pb_unit_tests/message_test_wrapper.py | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/descriptor.c b/python/descriptor.c index 543c9d7a8c..c60bbec183 100644 --- a/python/descriptor.c +++ b/python/descriptor.c @@ -1011,6 +1011,12 @@ static PyObject* PyUpb_FieldDescriptor_GetHasOptions( return PyBool_FromLong(upb_FieldDef_HasOptions(self->def)); } +static PyObject* PyUpb_FieldDescriptor_GetHasPresence( + PyUpb_DescriptorBase* _self, void* closure) { + PyUpb_DescriptorBase* self = (void*)_self; + return PyBool_FromLong(upb_FieldDef_HasPresence(self->def)); +} + static PyObject* PyUpb_FieldDescriptor_GetOptions(PyObject* _self, PyObject* args) { PyUpb_DescriptorBase* self = (void*)_self; @@ -1049,6 +1055,8 @@ static PyGetSetDef PyUpb_FieldDescriptor_Getters[] = { "Containing oneof"}, {"has_options", (getter)PyUpb_FieldDescriptor_GetHasOptions, NULL, "Has Options"}, + {"has_presence", (getter)PyUpb_FieldDescriptor_GetHasPresence, NULL, + "Has Presence"}, // TODO(https://github.com/protocolbuffers/upb/issues/459) //{ "_options", //(getter)NULL, (setter)SetOptions, "Options"}, { "_serialized_options", diff --git a/python/pb_unit_tests/message_test_wrapper.py b/python/pb_unit_tests/message_test_wrapper.py index 37d8b15741..dde0d94188 100644 --- a/python/pb_unit_tests/message_test_wrapper.py +++ b/python/pb_unit_tests/message_test_wrapper.py @@ -51,7 +51,6 @@ MessageTest.testPickleRepeatedScalarContainer_proto3.__unittest_expecting_failur Proto2Test.testPythonicInit.__unittest_expecting_failure__ = True Proto2Test.test_documentation.__unittest_expecting_failure__ = True Proto3Test.testModifyMapEntryWhileIterating.__unittest_expecting_failure__ = True -Proto3Test.testProto3Optional.__unittest_expecting_failure__ = True if __name__ == '__main__': unittest.main(verbosity=2)