def assertIntegerTypes(self, integer_fn, message_module):
    """Verifies setting of scalar integers.

    Args:
      integer_fn: A function to wrap the integers that will be assigned.
      message_module: unittest_pb2 or unittest_proto3_arena_pb2
    """
    def TestGetAndDeserialize(field_name, value, expected_type):
      proto = message_module.TestAllTypes()
      value = integer_fn(value)
      setattr(proto, field_name, value)
      self.assertIsInstance(getattr(proto, field_name), expected_type)
      proto2 = message_module.TestAllTypes()
      proto2.ParseFromString(proto.SerializeToString())
      self.assertIsInstance(getattr(proto2, field_name), expected_type)

    TestGetAndDeserialize('optional_int32', 1, int)
    TestGetAndDeserialize('optional_int32', 1 << 30, int)
    TestGetAndDeserialize('optional_uint32', 1 << 30, int)
    integer_64 = int
    if struct.calcsize('L') == 4:
      # Python only has signed ints, so 32-bit python can't fit an uint32
      # in an int.
      TestGetAndDeserialize('optional_uint32', 1 << 31, integer_64)
    else:
      # 64-bit python can fit uint32 inside an int
      TestGetAndDeserialize('optional_uint32', 1 << 31, int)
    TestGetAndDeserialize('optional_int64', 1 << 30, integer_64)
    TestGetAndDeserialize('optional_int64', 1 << 60, integer_64)
    TestGetAndDeserialize('optional_uint64', 1 << 30, integer_64)
    TestGetAndDeserialize('optional_uint64', 1 << 60, integer_64)
Verifies setting of scalar integers.

    Args:
      integer_fn: A function to wrap the integers that will be assigned.
      message_module: unittest_pb2 or unittest_proto3_arena_pb2
    
deps/protobuf/python/google/protobuf/internal/reflection_test.py