Internal change

PiperOrigin-RevId: 532155491
pull/12800/head
Jie Luo 2 years ago committed by Copybara-Service
parent fc7454acf8
commit 3b8a472d07
  1. 19
      python/google/protobuf/internal/descriptor_pool_test.py
  2. 2
      python/google/protobuf/pyext/descriptor_pool.cc

@ -925,10 +925,9 @@ class AddDescriptorTest(unittest.TestCase):
def _TestEnum(self, prefix): def _TestEnum(self, prefix):
pool = descriptor_pool.DescriptorPool() pool = descriptor_pool.DescriptorPool()
if api_implementation.Type() == 'cpp': pool.AddSerializedFile(unittest_import_public_pb2.DESCRIPTOR.serialized_pb)
pool.AddEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR) pool.AddSerializedFile(unittest_import_pb2.DESCRIPTOR.serialized_pb)
else: pool.AddSerializedFile(unittest_pb2.DESCRIPTOR.serialized_pb)
pool._AddEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR)
self.assertEqual( self.assertEqual(
'protobuf_unittest.ForeignEnum', 'protobuf_unittest.ForeignEnum',
pool.FindEnumTypeByName( pool.FindEnumTypeByName(
@ -939,10 +938,6 @@ class AddDescriptorTest(unittest.TestCase):
pool.FindEnumTypeByName( pool.FindEnumTypeByName(
prefix + 'protobuf_unittest.ForeignEnum.NestedEnum') prefix + 'protobuf_unittest.ForeignEnum.NestedEnum')
if api_implementation.Type() == 'cpp':
pool.AddEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR)
else:
pool._AddEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR)
self.assertEqual( self.assertEqual(
'protobuf_unittest.TestAllTypes.NestedEnum', 'protobuf_unittest.TestAllTypes.NestedEnum',
pool.FindEnumTypeByName( pool.FindEnumTypeByName(
@ -1057,14 +1052,6 @@ class AddDescriptorTest(unittest.TestCase):
if api_implementation.Type() != 'python': if api_implementation.Type() != 'python':
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
pool.AddDescriptor(0) pool.AddDescriptor(0)
with self.assertRaises(TypeError):
pool.AddEnumDescriptor(0)
with self.assertRaises(TypeError):
pool.AddServiceDescriptor(0)
with self.assertRaises(TypeError):
pool.AddExtensionDescriptor(0)
with self.assertRaises(TypeError):
pool.AddFileDescriptor(0)
else: else:
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
pool._AddDescriptor(0) pool._AddDescriptor(0)

@ -664,8 +664,6 @@ static PyMethodDef Methods[] = {
{"AddSerializedFile", AddSerializedFile, METH_O, {"AddSerializedFile", AddSerializedFile, METH_O,
"Adds a serialized FileDescriptorProto to this pool."}, "Adds a serialized FileDescriptorProto to this pool."},
// TODO(amauryfa): Understand why the Python implementation differs from
// this one, ask users to use another API and deprecate these functions.
{"AddFileDescriptor", AddFileDescriptor, METH_O, {"AddFileDescriptor", AddFileDescriptor, METH_O,
"No-op. Add() must have been called before."}, "No-op. Add() must have been called before."},
{"AddDescriptor", AddDescriptor, METH_O, {"AddDescriptor", AddDescriptor, METH_O,

Loading…
Cancel
Save