code: def testUnknownEnumValue(self):
      if api_implementation.Type() == "cpp":
          # The CPP implementation of protos (wrongly) allows unknown enum values
          # for proto2.
          self.assertTrue(
              self.missing_message.HasField("optional_nested_enum")
          )
          self.assertEqual(
              self.message.optional_nested_enum,
              self.missing_message.optional_nested_enum,
          )
      else:
          # On the other hand, the Python implementation considers unknown values
          # as unknown fields. This is the correct behavior.
          self.assertFalse(
              self.missing_message.HasField("optional_nested_enum")
          )
          value = self.GetUnknownField("optional_nested_enum")
          self.assertEqual(self.message.optional_nested_enum, value)
      self.missing_message.ClearField("optional_nested_enum")
      self.assertFalse(
          self.missing_message.HasField("optional_nested_enum")
      )
  
imports: from google.protobuf import unittest_mset_pb2
  from google.protobuf import unittest_pb2
  from google.protobuf import unittest_proto3_arena_pb2
  from google.protobuf.internal import api_implementation
  from google.protobuf.internal import encoder
  from google.protobuf.internal import message_set_extensions_pb2
  from google.protobuf.internal import missing_enum_values_pb2
  from google.protobuf.internal import test_util
  from google.protobuf.internal import testing_refleaks
  from google.protobuf.internal import type_checkers
label_desc: Use image node_id 4 for calling the UnknownEnumValuesTest obj's underlying member method code with example usage: obj.testUnknownEnumValue() without return types