2024-09-11 08:27:29 -07:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# Protocol Buffers - Google's data interchange format
|
|
|
|
|
# Copyright 2008 Google Inc. All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
|
# https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
|
|
"""Unittest for reflection.py, with C++ protos linked in."""
|
|
|
|
|
|
|
|
|
|
import copy
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from google.protobuf.internal import testing_refleaks
|
2026-04-29 13:39:31 -07:00
|
|
|
|
2024-12-16 18:52:17 -08:00
|
|
|
from absl.testing import parameterized
|
2024-09-11 08:27:29 -07:00
|
|
|
from google.protobuf import unittest_pb2
|
|
|
|
|
from google.protobuf import unittest_proto3_arena_pb2
|
|
|
|
|
|
|
|
|
|
|
2024-12-16 18:52:17 -08:00
|
|
|
@parameterized.named_parameters(
|
2024-09-11 08:27:29 -07:00
|
|
|
('_proto2', unittest_pb2), ('_proto3', unittest_proto3_arena_pb2)
|
|
|
|
|
)
|
|
|
|
|
@testing_refleaks.TestCase
|
|
|
|
|
class ReflectionTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
def testEmptyCompositeContainerDeepCopy(self, message_module):
|
|
|
|
|
proto1 = message_module.NestedTestAllTypes(
|
|
|
|
|
payload=message_module.TestAllTypes(optional_string='foo')
|
|
|
|
|
)
|
|
|
|
|
nested2 = copy.deepcopy(proto1.child.repeated_child)
|
|
|
|
|
self.assertEqual(0, len(nested2))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|