Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: third_party/protobuf/python/google/protobuf/internal/descriptor_pool_test.py

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/python/google/protobuf/internal/descriptor_pool_test.py
diff --git a/third_party/protobuf/python/google/protobuf/internal/descriptor_pool_test.py b/third_party/protobuf/python/google/protobuf/internal/descriptor_pool_test.py
index 1e710dcf82b1a8f57e8ae697b647b24ab7a0dc7b..6a13e0bcf0b9796d8a9e734af22e797850df2b8e 100644
--- a/third_party/protobuf/python/google/protobuf/internal/descriptor_pool_test.py
+++ b/third_party/protobuf/python/google/protobuf/internal/descriptor_pool_test.py
@@ -51,7 +51,6 @@ from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
-from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf import descriptor
from google.protobuf import descriptor_database
@@ -119,7 +118,6 @@ class DescriptorPoolTest(unittest.TestCase):
self.assertEqual('google.protobuf.python.internal.Factory1Message',
msg1.full_name)
self.assertEqual(None, msg1.containing_type)
- self.assertFalse(msg1.has_options)
nested_msg1 = msg1.nested_types[0]
self.assertEqual('NestedFactory1Message', nested_msg1.name)
@@ -203,7 +201,6 @@ class DescriptorPoolTest(unittest.TestCase):
self.assertIsInstance(enum1, descriptor.EnumDescriptor)
self.assertEqual(0, enum1.values_by_name['FACTORY_1_VALUE_0'].number)
self.assertEqual(1, enum1.values_by_name['FACTORY_1_VALUE_1'].number)
- self.assertFalse(enum1.has_options)
nested_enum1 = self.pool.FindEnumTypeByName(
'google.protobuf.python.internal.Factory1Message.NestedFactory1Enum')
@@ -236,8 +233,6 @@ class DescriptorPoolTest(unittest.TestCase):
'google.protobuf.python.internal.Factory1Message.list_value')
self.assertEqual(field.name, 'list_value')
self.assertEqual(field.label, field.LABEL_REPEATED)
- self.assertFalse(field.has_options)
-
with self.assertRaises(KeyError):
self.pool.FindFieldByName('Does not exist')
@@ -254,53 +249,6 @@ class DescriptorPoolTest(unittest.TestCase):
with self.assertRaises(KeyError):
self.pool.FindFieldByName('Does not exist')
- def testFindAllExtensions(self):
- factory1_message = self.pool.FindMessageTypeByName(
- 'google.protobuf.python.internal.Factory1Message')
- factory2_message = self.pool.FindMessageTypeByName(
- 'google.protobuf.python.internal.Factory2Message')
- # An extension defined in a message.
- one_more_field = factory2_message.extensions_by_name['one_more_field']
- self.pool.AddExtensionDescriptor(one_more_field)
- # An extension defined at file scope.
- factory_test2 = self.pool.FindFileByName(
- 'google/protobuf/internal/factory_test2.proto')
- another_field = factory_test2.extensions_by_name['another_field']
- self.pool.AddExtensionDescriptor(another_field)
-
- extensions = self.pool.FindAllExtensions(factory1_message)
- expected_extension_numbers = set([one_more_field, another_field])
- self.assertEqual(expected_extension_numbers, set(extensions))
- # Verify that mutating the returned list does not affect the pool.
- extensions.append('unexpected_element')
- # Get the extensions again, the returned value does not contain the
- # 'unexpected_element'.
- extensions = self.pool.FindAllExtensions(factory1_message)
- self.assertEqual(expected_extension_numbers, set(extensions))
-
- def testFindExtensionByNumber(self):
- factory1_message = self.pool.FindMessageTypeByName(
- 'google.protobuf.python.internal.Factory1Message')
- factory2_message = self.pool.FindMessageTypeByName(
- 'google.protobuf.python.internal.Factory2Message')
- # An extension defined in a message.
- one_more_field = factory2_message.extensions_by_name['one_more_field']
- self.pool.AddExtensionDescriptor(one_more_field)
- # An extension defined at file scope.
- factory_test2 = self.pool.FindFileByName(
- 'google/protobuf/internal/factory_test2.proto')
- another_field = factory_test2.extensions_by_name['another_field']
- self.pool.AddExtensionDescriptor(another_field)
-
- # An extension defined in a message.
- extension = self.pool.FindExtensionByNumber(factory1_message, 1001)
- self.assertEqual(extension.name, 'one_more_field')
- # An extension defined at file scope.
- extension = self.pool.FindExtensionByNumber(factory1_message, 1002)
- self.assertEqual(extension.name, 'another_field')
- with self.assertRaises(KeyError):
- extension = self.pool.FindExtensionByNumber(factory1_message, 1234567)
-
def testExtensionsAreNotFields(self):
with self.assertRaises(KeyError):
self.pool.FindFieldByName('google.protobuf.python.internal.another_field')
@@ -499,7 +447,6 @@ class EnumField(object):
test.assertTrue(field_desc.has_default_value)
test.assertEqual(enum_desc.values_by_name[self.default_value].number,
field_desc.default_value)
- test.assertFalse(enum_desc.values_by_name[self.default_value].has_options)
test.assertEqual(msg_desc, field_desc.containing_type)
test.assertEqual(enum_desc, field_desc.enum_type)
@@ -683,23 +630,6 @@ class AddDescriptorTest(unittest.TestCase):
self.assertEqual(pool.FindMessageTypeByName('package.Message').name,
'Message')
- def testFileDescriptorOptionsWithCustomDescriptorPool(self):
- # Create a descriptor pool, and add a new FileDescriptorProto to it.
- pool = descriptor_pool.DescriptorPool()
- file_name = 'file_descriptor_options_with_custom_descriptor_pool.proto'
- file_descriptor_proto = descriptor_pb2.FileDescriptorProto(name=file_name)
- extension_id = file_options_test_pb2.foo_options
- file_descriptor_proto.options.Extensions[extension_id].foo_name = 'foo'
- pool.Add(file_descriptor_proto)
- # The options set on the FileDescriptorProto should be available in the
- # descriptor even if they contain extensions that cannot be deserialized
- # using the pool.
- file_descriptor = pool.FindFileByName(file_name)
- options = file_descriptor.GetOptions()
- self.assertEqual('foo', options.Extensions[extension_id].foo_name)
- # The object returned by GetOptions() is cached.
- self.assertIs(options, file_descriptor.GetOptions())
-
@unittest.skipIf(
api_implementation.Type() != 'cpp',

Powered by Google App Engine
This is Rietveld 408576698