diff options
author | Adam Cozzette <acozzette@google.com> | 2017-12-01 10:05:10 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2017-12-01 10:05:10 -0800 |
commit | 92a7e778e7394386f413cec28d67a07630f784b1 (patch) | |
tree | cb5673c7c09b0d3905b48a24765d07e423bc5b30 /python/google/protobuf/internal/descriptor_database_test.py | |
parent | ce0a53273a400369932ba788d17500336a6ecaad (diff) | |
download | protobuf-92a7e778e7394386f413cec28d67a07630f784b1.tar.gz protobuf-92a7e778e7394386f413cec28d67a07630f784b1.tar.bz2 protobuf-92a7e778e7394386f413cec28d67a07630f784b1.zip |
Integrated internal changes from Google
Diffstat (limited to 'python/google/protobuf/internal/descriptor_database_test.py')
-rw-r--r-- | python/google/protobuf/internal/descriptor_database_test.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/python/google/protobuf/internal/descriptor_database_test.py b/python/google/protobuf/internal/descriptor_database_test.py index 1f1a3db9..f97477b3 100644 --- a/python/google/protobuf/internal/descriptor_database_test.py +++ b/python/google/protobuf/internal/descriptor_database_test.py @@ -38,6 +38,7 @@ try: import unittest2 as unittest #PY26 except ImportError: import unittest +import warnings from google.protobuf import unittest_pb2 from google.protobuf import descriptor_pb2 @@ -98,6 +99,26 @@ class DescriptorDatabaseTest(unittest.TestCase): db.FindFileContainingSymbol, 'protobuf_unittest.NoneMessage') + def testConflictRegister(self): + db = descriptor_database.DescriptorDatabase() + unittest_fd = descriptor_pb2.FileDescriptorProto.FromString( + unittest_pb2.DESCRIPTOR.serialized_pb) + db.Add(unittest_fd) + conflict_fd = descriptor_pb2.FileDescriptorProto.FromString( + unittest_pb2.DESCRIPTOR.serialized_pb) + conflict_fd.name = 'other_file' + with warnings.catch_warnings(record=True) as w: + # Cause all warnings to always be triggered. + warnings.simplefilter('always') + db.Add(conflict_fd) + self.assertTrue(len(w)) + self.assertIs(w[0].category, RuntimeWarning) + self.assertIn('Conflict register for file "other_file": ', + str(w[0].message)) + self.assertIn('already defined in file ' + '"google/protobuf/unittest.proto"', + str(w[0].message)) + if __name__ == '__main__': unittest.main() |