code: def testAnyMessage(self):
      # Creates and sets message.
      msg = any_test_pb2.TestAny()
      msg_descriptor = msg.DESCRIPTOR
      all_types = unittest_pb2.TestAllTypes()
      all_descriptor = all_types.DESCRIPTOR
      all_types.repeated_string.append("\u00fc\ua71f")
      # Packs to Any.
      msg.value.Pack(all_types)
      self.assertEqual(
          msg.value.type_url,
          "type.googleapis.com/%s" % all_descriptor.full_name,
      )
      self.assertEqual(msg.value.value, all_types.SerializeToString())
      # Tests Is() method.
      self.assertTrue(msg.value.Is(all_descriptor))
      self.assertFalse(msg.value.Is(msg_descriptor))
      # Unpacks Any.
      unpacked_message = unittest_pb2.TestAllTypes()
      self.assertTrue(msg.value.Unpack(unpacked_message))
      self.assertEqual(all_types, unpacked_message)
      # Unpacks to different type.
      self.assertFalse(msg.value.Unpack(msg))
      # Only Any messages have Pack method.
      try:
          msg.Pack(all_types)
      except AttributeError:
          pass
      else:
          raise AttributeError(
              "%s should not have Pack method."
              % msg_descriptor.full_name
          )
  
imports: from datetime import datetime
  from google.protobuf import any_pb2
  from google.protobuf import duration_pb2
  from google.protobuf import field_mask_pb2
  from google.protobuf import struct_pb2
  from google.protobuf import timestamp_pb2
  from google.protobuf import unittest_pb2
  from google.protobuf.internal import any_test_pb2
  from google.protobuf.internal import test_util
  from google.protobuf.internal import well_known_types
  from google.protobuf import descriptor
  from google.protobuf import text_format
label_desc: Use image node_id 1 for calling the AnyTest obj's underlying member method code with example usage: obj.testAnyMessage() without return types