Index: third_party/protobuf/python/google/protobuf/internal/message_test.py |
diff --git a/third_party/protobuf/python/google/protobuf/internal/message_test.py b/third_party/protobuf/python/google/protobuf/internal/message_test.py |
index 9986c0d99bfc8913e2b2e629bd4dfac34936c14f..4ee31d8ed97cf4255d613672b942a094fafe7239 100755 |
--- a/third_party/protobuf/python/google/protobuf/internal/message_test.py |
+++ b/third_party/protobuf/python/google/protobuf/internal/message_test.py |
@@ -67,7 +67,6 @@ from google.protobuf import text_format |
from google.protobuf.internal import api_implementation |
from google.protobuf.internal import packed_field_test_pb2 |
from google.protobuf.internal import test_util |
-from google.protobuf.internal import testing_refleaks |
from google.protobuf import message |
from google.protobuf.internal import _parameterized |
@@ -89,13 +88,10 @@ def IsNegInf(val): |
return isinf(val) and (val < 0) |
-BaseTestCase = testing_refleaks.BaseTestCase |
- |
- |
-@_parameterized.NamedParameters( |
- ('_proto2', unittest_pb2), |
- ('_proto3', unittest_proto3_arena_pb2)) |
-class MessageTest(BaseTestCase): |
+@_parameterized.Parameters( |
+ (unittest_pb2), |
+ (unittest_proto3_arena_pb2)) |
+class MessageTest(unittest.TestCase): |
def testBadUtf8String(self, message_module): |
if api_implementation.Type() != 'python': |
@@ -961,7 +957,7 @@ class MessageTest(BaseTestCase): |
# Class to test proto2-only features (required, extensions, etc.) |
-class Proto2Test(BaseTestCase): |
+class Proto2Test(unittest.TestCase): |
def testFieldPresence(self): |
message = unittest_pb2.TestAllTypes() |
@@ -1117,7 +1113,6 @@ class Proto2Test(BaseTestCase): |
optional_bytes=b'x', |
optionalgroup={'a': 400}, |
optional_nested_message={'bb': 500}, |
- optional_foreign_message={}, |
optional_nested_enum='BAZ', |
repeatedgroup=[{'a': 600}, |
{'a': 700}], |
@@ -1130,12 +1125,8 @@ class Proto2Test(BaseTestCase): |
self.assertEqual(300.5, message.optional_float) |
self.assertEqual(b'x', message.optional_bytes) |
self.assertEqual(400, message.optionalgroup.a) |
- self.assertIsInstance(message.optional_nested_message, |
- unittest_pb2.TestAllTypes.NestedMessage) |
+ self.assertIsInstance(message.optional_nested_message, unittest_pb2.TestAllTypes.NestedMessage) |
self.assertEqual(500, message.optional_nested_message.bb) |
- self.assertTrue(message.HasField('optional_foreign_message')) |
- self.assertEqual(message.optional_foreign_message, |
- unittest_pb2.ForeignMessage()) |
self.assertEqual(unittest_pb2.TestAllTypes.BAZ, |
message.optional_nested_enum) |
self.assertEqual(2, len(message.repeatedgroup)) |
@@ -1173,7 +1164,7 @@ class Proto2Test(BaseTestCase): |
# Class to test proto3-only features/behavior (updated field presence & enums) |
-class Proto3Test(BaseTestCase): |
+class Proto3Test(unittest.TestCase): |
# Utility method for comparing equality with a map. |
def assertMapIterEquals(self, map_iter, dict_value): |
@@ -1444,8 +1435,6 @@ class Proto3Test(BaseTestCase): |
msg2.map_int32_int32[12] = 55 |
msg2.map_int64_int64[88] = 99 |
msg2.map_int32_foreign_message[222].c = 15 |
- msg2.map_int32_foreign_message[222].d = 20 |
- old_map_value = msg2.map_int32_foreign_message[222] |
msg2.MergeFrom(msg) |
@@ -1455,8 +1444,6 @@ class Proto3Test(BaseTestCase): |
self.assertEqual(99, msg2.map_int64_int64[88]) |
self.assertEqual(5, msg2.map_int32_foreign_message[111].c) |
self.assertEqual(10, msg2.map_int32_foreign_message[222].c) |
- self.assertFalse(msg2.map_int32_foreign_message[222].HasField('d')) |
- self.assertEqual(15, old_map_value.c) |
# Verify that there is only one entry per key, even though the MergeFrom |
# may have internally created multiple entries for a single key in the |
@@ -1729,7 +1716,7 @@ class Proto3Test(BaseTestCase): |
-class ValidTypeNamesTest(BaseTestCase): |
+class ValidTypeNamesTest(unittest.TestCase): |
def assertImportFromName(self, msg, base_name): |
# Parse <type 'module.class_name'> to extra 'some.name' as a string. |
@@ -1750,7 +1737,7 @@ class ValidTypeNamesTest(BaseTestCase): |
self.assertImportFromName(pb.repeated_int32, 'Scalar') |
self.assertImportFromName(pb.repeated_nested_message, 'Composite') |
-class PackedFieldTest(BaseTestCase): |
+class PackedFieldTest(unittest.TestCase): |
def setMessage(self, message): |
message.repeated_int32.append(1) |
@@ -1809,14 +1796,10 @@ class PackedFieldTest(BaseTestCase): |
@unittest.skipIf(api_implementation.Type() != 'cpp', |
'explicit tests of the C++ implementation') |
-class OversizeProtosTest(BaseTestCase): |
- |
- @classmethod |
- def setUpClass(cls): |
- # At the moment, reference cycles between DescriptorPool and Message classes |
- # are not detected and these objects are never freed. |
- # To avoid errors with ReferenceLeakChecker, we create the class only once. |
- file_desc = """ |
+class OversizeProtosTest(unittest.TestCase): |
+ |
+ def setUp(self): |
+ self.file_desc = """ |
name: "f/f.msg2" |
package: "f" |
message_type { |
@@ -1841,12 +1824,10 @@ class OversizeProtosTest(BaseTestCase): |
""" |
pool = descriptor_pool.DescriptorPool() |
desc = descriptor_pb2.FileDescriptorProto() |
- text_format.Parse(file_desc, desc) |
+ text_format.Parse(self.file_desc, desc) |
pool.Add(desc) |
- cls.proto_cls = message_factory.MessageFactory(pool).GetPrototype( |
+ self.proto_cls = message_factory.MessageFactory(pool).GetPrototype( |
pool.FindMessageTypeByName('f.msg2')) |
- |
- def setUp(self): |
self.p = self.proto_cls() |
self.p.field.payload = 'c' * (1024 * 1024 * 64 + 1) |
self.p_serialized = self.p.SerializeToString() |