aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/internal
diff options
context:
space:
mode:
authorGravatar Jie Luo <anandolee@gmail.com>2017-04-10 16:37:57 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2017-04-10 16:37:57 -0700
commit899460c9cb328e51b5da0ffe5d73e03c8f00dd15 (patch)
tree882fc6e219956b77f3f30c8560b10c017fa7f61f /python/google/protobuf/internal
parente91caa1f197ec1bd48a713c435c47e6f3948a1fb (diff)
cherrypick descriptor_pool.FindFileContainingSymbol by extensions (#2962)
* Use PyUnicode_AsEncodedString() instead of PyUnicode_AsEncodedObject() * Cherrypick the fix descriptor_pool.FindFileContainingSymbol by extensions.
Diffstat (limited to 'python/google/protobuf/internal')
-rw-r--r--python/google/protobuf/internal/descriptor_pool_test.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/python/google/protobuf/internal/descriptor_pool_test.py b/python/google/protobuf/internal/descriptor_pool_test.py
index 2ba1d285..c1733a48 100644
--- a/python/google/protobuf/internal/descriptor_pool_test.py
+++ b/python/google/protobuf/internal/descriptor_pool_test.py
@@ -63,6 +63,9 @@ from google.protobuf import symbol_database
class DescriptorPoolTest(unittest.TestCase):
def setUp(self):
+ # TODO(jieluo): Should make the pool which is created by
+ # serialized_pb same with generated pool.
+ # TODO(jieluo): More test coverage for the generated pool.
self.pool = descriptor_pool.DescriptorPool()
self.factory_test1_fd = descriptor_pb2.FileDescriptorProto.FromString(
factory_test1_pb2.DESCRIPTOR.serialized_pb)
@@ -128,6 +131,12 @@ class DescriptorPoolTest(unittest.TestCase):
self.assertEqual('google/protobuf/internal/factory_test2.proto',
file_desc4.name)
+ # Tests the generated pool.
+ assert descriptor_pool.Default().FindFileContainingSymbol(
+ 'google.protobuf.python.internal.Factory2Message.one_more_field')
+ assert descriptor_pool.Default().FindFileContainingSymbol(
+ 'google.protobuf.python.internal.another_field')
+
def testFindFileContainingSymbolFailure(self):
with self.assertRaises(KeyError):
self.pool.FindFileContainingSymbol('Does not exist')