Drop dependency on 'google.apputils'.

Use stdlib's 'unittest' instead.
pull/165/head
Tres Seaver 10 years ago
parent 052e0205a7
commit 7ee25830c6
  1. 6
      python/google/protobuf/internal/api_implementation_default_test.py
  2. 7
      python/google/protobuf/internal/descriptor_database_test.py
  3. 7
      python/google/protobuf/internal/descriptor_pool_test.py
  4. 6
      python/google/protobuf/internal/descriptor_python_test.py
  5. 11
      python/google/protobuf/internal/descriptor_test.py
  6. 9
      python/google/protobuf/internal/generator_test.py
  7. 6
      python/google/protobuf/internal/message_factory_python_test.py
  8. 22
      python/google/protobuf/internal/message_factory_test.py
  9. 6
      python/google/protobuf/internal/message_python_test.py
  10. 8
      python/google/protobuf/internal/message_test.py
  11. 6
      python/google/protobuf/internal/proto_builder_test.py
  12. 26
      python/google/protobuf/internal/reflection_test.py
  13. 7
      python/google/protobuf/internal/service_reflection_test.py
  14. 7
      python/google/protobuf/internal/symbol_database_test.py
  15. 7
      python/google/protobuf/internal/text_encoding_test.py
  16. 8
      python/google/protobuf/internal/text_format_test.py
  17. 13
      python/google/protobuf/internal/unknown_fields_test.py
  18. 7
      python/google/protobuf/internal/wire_format_test.py
  19. 6
      python/google/protobuf/pyext/descriptor_cpp2_test.py
  20. 6
      python/google/protobuf/pyext/message_factory_cpp2_test.py
  21. 6
      python/google/protobuf/pyext/reflection_cpp2_generated_test.py
  22. 5
      python/setup.py

@ -34,16 +34,16 @@
import os import os
import sys import sys
import unittest
# Clear environment implementation settings before the google3 imports. # Clear environment implementation settings before the google3 imports.
os.environ.pop('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION', None) os.environ.pop('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION', None)
os.environ.pop('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION', None) os.environ.pop('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION', None)
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
class ApiImplementationDefaultTest(basetest.TestCase): class ApiImplementationDefaultTest(unittest.TestCase):
if sys.version_info.major <= 2: if sys.version_info.major <= 2:
@ -60,4 +60,4 @@ class ApiImplementationDefaultTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -34,13 +34,14 @@
__author__ = 'matthewtoia@google.com (Matt Toia)' __author__ = 'matthewtoia@google.com (Matt Toia)'
from google.apputils import basetest import unittest
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf.internal import factory_test2_pb2 from google.protobuf.internal import factory_test2_pb2
from google.protobuf import descriptor_database from google.protobuf import descriptor_database
class DescriptorDatabaseTest(basetest.TestCase): class DescriptorDatabaseTest(unittest.TestCase):
def testAdd(self): def testAdd(self):
db = descriptor_database.DescriptorDatabase() db = descriptor_database.DescriptorDatabase()
@ -62,4 +63,4 @@ class DescriptorDatabaseTest(basetest.TestCase):
'google.protobuf.python.internal.MessageWithNestedEnumOnly.NestedEnum')) 'google.protobuf.python.internal.MessageWithNestedEnumOnly.NestedEnum'))
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -37,7 +37,6 @@ __author__ = 'matthewtoia@google.com (Matt Toia)'
import os import os
import unittest import unittest
from google.apputils import basetest
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
@ -51,7 +50,7 @@ from google.protobuf import descriptor_pool
from google.protobuf import symbol_database from google.protobuf import symbol_database
class DescriptorPoolTest(basetest.TestCase): class DescriptorPoolTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.pool = descriptor_pool.DescriptorPool() self.pool = descriptor_pool.DescriptorPool()
@ -426,7 +425,7 @@ class ExtensionField(object):
test.assertEqual(self.extended_type, field_desc.containing_type.name) test.assertEqual(self.extended_type, field_desc.containing_type.name)
class AddDescriptorTest(basetest.TestCase): class AddDescriptorTest(unittest.TestCase):
def _TestMessage(self, prefix): def _TestMessage(self, prefix):
pool = descriptor_pool.DescriptorPool() pool = descriptor_pool.DescriptorPool()
@ -588,4 +587,4 @@ TEST2_FILE = ProtoFile(
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -33,22 +33,22 @@
"""Unittest for descriptor.py for the pure Python implementation.""" """Unittest for descriptor.py for the pure Python implementation."""
import os import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
# We must set the implementation version above before the google3 imports. # We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace. # Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
from google.protobuf.internal.descriptor_test import * from google.protobuf.internal.descriptor_test import *
class ConfirmPurePythonTest(basetest.TestCase): class ConfirmPurePythonTest(unittest.TestCase):
def testImplementationSetting(self): def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type()) self.assertEqual('python', api_implementation.Type())
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -34,7 +34,8 @@
__author__ = 'robinson@google.com (Will Robinson)' __author__ = 'robinson@google.com (Will Robinson)'
from google.apputils import basetest import unittest
from google.protobuf import unittest_custom_options_pb2 from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
@ -48,7 +49,7 @@ name: 'TestEmptyMessage'
""" """
class DescriptorTest(basetest.TestCase): class DescriptorTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.my_file = descriptor.FileDescriptor( self.my_file = descriptor.FileDescriptor(
@ -395,7 +396,7 @@ class DescriptorTest(basetest.TestCase):
self.assertEqual(self.my_file.package, 'protobuf_unittest') self.assertEqual(self.my_file.package, 'protobuf_unittest')
class DescriptorCopyToProtoTest(basetest.TestCase): class DescriptorCopyToProtoTest(unittest.TestCase):
"""Tests for CopyTo functions of Descriptor.""" """Tests for CopyTo functions of Descriptor."""
def _AssertProtoEqual(self, actual_proto, expected_class, expected_ascii): def _AssertProtoEqual(self, actual_proto, expected_class, expected_ascii):
@ -594,7 +595,7 @@ class DescriptorCopyToProtoTest(basetest.TestCase):
TEST_SERVICE_ASCII) TEST_SERVICE_ASCII)
class MakeDescriptorTest(basetest.TestCase): class MakeDescriptorTest(unittest.TestCase):
def testMakeDescriptorWithNestedFields(self): def testMakeDescriptorWithNestedFields(self):
file_descriptor_proto = descriptor_pb2.FileDescriptorProto() file_descriptor_proto = descriptor_pb2.FileDescriptorProto()
@ -676,4 +677,4 @@ class MakeDescriptorTest(basetest.TestCase):
options.Extensions[unittest_custom_options_pb2.msgopt].i) options.Extensions[unittest_custom_options_pb2.msgopt].i)
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -41,7 +41,8 @@ further ensures that we can use Python protocol message objects as we expect.
__author__ = 'robinson@google.com (Will Robinson)' __author__ = 'robinson@google.com (Will Robinson)'
from google.apputils import basetest import unittest
from google.protobuf.internal import test_bad_identifiers_pb2 from google.protobuf.internal import test_bad_identifiers_pb2
from google.protobuf import unittest_custom_options_pb2 from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_import_pb2
@ -55,7 +56,7 @@ from google.protobuf import symbol_database
MAX_EXTENSION = 536870912 MAX_EXTENSION = 536870912
class GeneratorTest(basetest.TestCase): class GeneratorTest(unittest.TestCase):
def testNestedMessageDescriptor(self): def testNestedMessageDescriptor(self):
field_name = 'optional_nested_message' field_name = 'optional_nested_message'
@ -301,7 +302,7 @@ class GeneratorTest(basetest.TestCase):
self.assertIsNone(field_desc.containing_oneof) self.assertIsNone(field_desc.containing_oneof)
class SymbolDatabaseRegistrationTest(basetest.TestCase): class SymbolDatabaseRegistrationTest(unittest.TestCase):
"""Checks that messages, enums and files are correctly registered.""" """Checks that messages, enums and files are correctly registered."""
def testGetSymbol(self): def testGetSymbol(self):
@ -340,4 +341,4 @@ class SymbolDatabaseRegistrationTest(basetest.TestCase):
'google/protobuf/unittest.proto').name) 'google/protobuf/unittest.proto').name)
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -33,22 +33,22 @@
"""Tests for ..public.message_factory for the pure Python implementation.""" """Tests for ..public.message_factory for the pure Python implementation."""
import os import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
# We must set the implementation version above before the google3 imports. # We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace. # Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
from google.protobuf.internal.message_factory_test import * from google.protobuf.internal.message_factory_test import *
class ConfirmPurePythonTest(basetest.TestCase): class ConfirmPurePythonTest(unittest.TestCase):
def testImplementationSetting(self): def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type()) self.assertEqual('python', api_implementation.Type())
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -34,7 +34,8 @@
__author__ = 'matthewtoia@google.com (Matt Toia)' __author__ = 'matthewtoia@google.com (Matt Toia)'
from google.apputils import basetest import unittest
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf.internal import factory_test1_pb2 from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2 from google.protobuf.internal import factory_test2_pb2
@ -43,7 +44,7 @@ from google.protobuf import descriptor_pool
from google.protobuf import message_factory from google.protobuf import message_factory
class MessageFactoryTest(basetest.TestCase): class MessageFactoryTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.factory_test1_fd = descriptor_pb2.FileDescriptorProto.FromString( self.factory_test1_fd = descriptor_pb2.FileDescriptorProto.FromString(
@ -104,17 +105,18 @@ class MessageFactoryTest(basetest.TestCase):
for _ in range(2): for _ in range(2):
messages = message_factory.GetMessages([self.factory_test2_fd, messages = message_factory.GetMessages([self.factory_test2_fd,
self.factory_test1_fd]) self.factory_test1_fd])
self.assertContainsSubset( self.assertTrue(
['google.protobuf.python.internal.Factory2Message', set(['google.protobuf.python.internal.Factory2Message',
'google.protobuf.python.internal.Factory1Message'], 'google.protobuf.python.internal.Factory1Message'],
messages.keys()) ).issubset(set(messages.keys())))
self._ExerciseDynamicClass( self._ExerciseDynamicClass(
messages['google.protobuf.python.internal.Factory2Message']) messages['google.protobuf.python.internal.Factory2Message'])
self.assertContainsSubset( self.assertTrue(
['google.protobuf.python.internal.Factory2Message.one_more_field', set(['google.protobuf.python.internal.Factory2Message.one_more_field',
'google.protobuf.python.internal.another_field'], 'google.protobuf.python.internal.another_field'],
(messages['google.protobuf.python.internal.Factory1Message'] ).issubset(
._extensions_by_name.keys())) set(messages['google.protobuf.python.internal.Factory1Message']
._extensions_by_name.keys())))
factory_msg1 = messages['google.protobuf.python.internal.Factory1Message'] factory_msg1 = messages['google.protobuf.python.internal.Factory1Message']
msg1 = messages['google.protobuf.python.internal.Factory1Message']() msg1 = messages['google.protobuf.python.internal.Factory1Message']()
ext1 = factory_msg1._extensions_by_name[ ext1 = factory_msg1._extensions_by_name[
@ -128,4 +130,4 @@ class MessageFactoryTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -33,22 +33,22 @@
"""Tests for ..public.message for the pure Python implementation.""" """Tests for ..public.message for the pure Python implementation."""
import os import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
# We must set the implementation version above before the google3 imports. # We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace. # Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
from google.protobuf.internal.message_test import * from google.protobuf.internal.message_test import *
class ConfirmPurePythonTest(basetest.TestCase): class ConfirmPurePythonTest(unittest.TestCase):
def testImplementationSetting(self): def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type()) self.assertEqual('python', api_implementation.Type())
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -48,8 +48,8 @@ import math
import operator import operator
import pickle import pickle
import sys import sys
import unittest
from google.apputils import basetest
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
from google.protobuf.internal import test_util from google.protobuf.internal import test_util
@ -69,7 +69,7 @@ def IsNegInf(val):
return isinf(val) and (val < 0) return isinf(val) and (val < 0)
class MessageTest(basetest.TestCase): class MessageTest(unittest.TestCase):
def testBadUtf8String(self): def testBadUtf8String(self):
if api_implementation.Type() != 'python': if api_implementation.Type() != 'python':
@ -695,7 +695,7 @@ class MessageTest(basetest.TestCase):
m.HasField('repeated_int32') m.HasField('repeated_int32')
class ValidTypeNamesTest(basetest.TestCase): class ValidTypeNamesTest(unittest.TestCase):
def assertImportFromName(self, msg, base_name): def assertImportFromName(self, msg, base_name):
# Parse <type 'module.class_name'> to extra 'some.name' as a string. # Parse <type 'module.class_name'> to extra 'some.name' as a string.
@ -718,4 +718,4 @@ class ValidTypeNamesTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -32,7 +32,7 @@
"""Tests for google.protobuf.proto_builder.""" """Tests for google.protobuf.proto_builder."""
from google.apputils import basetest import unittest
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool from google.protobuf import descriptor_pool
@ -40,7 +40,7 @@ from google.protobuf import proto_builder
from google.protobuf import text_format from google.protobuf import text_format
class ProtoBuilderTest(basetest.TestCase): class ProtoBuilderTest(unittest.TestCase):
def setUp(self): def setUp(self):
self._fields = { self._fields = {
@ -74,4 +74,4 @@ class ProtoBuilderTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -39,8 +39,8 @@ import copy
import gc import gc
import operator import operator
import struct import struct
import unittest
from google.apputils import basetest
from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2 from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
@ -102,7 +102,7 @@ class _MiniDecoder(object):
return self._pos == len(self._bytes) return self._pos == len(self._bytes)
class ReflectionTest(basetest.TestCase): class ReflectionTest(unittest.TestCase):
def assertListsEqual(self, values, others): def assertListsEqual(self, values, others):
self.assertEqual(len(values), len(others)) self.assertEqual(len(values), len(others))
@ -1619,7 +1619,7 @@ class ReflectionTest(basetest.TestCase):
self.assertFalse(proto.IsInitialized(errors)) self.assertFalse(proto.IsInitialized(errors))
self.assertEqual(errors, ['a', 'b', 'c']) self.assertEqual(errors, ['a', 'b', 'c'])
@basetest.unittest.skipIf( @unittest.skipIf(
api_implementation.Type() != 'cpp' or api_implementation.Version() != 2, api_implementation.Type() != 'cpp' or api_implementation.Version() != 2,
'Errors are only available from the most recent C++ implementation.') 'Errors are only available from the most recent C++ implementation.')
def testFileDescriptorErrors(self): def testFileDescriptorErrors(self):
@ -1797,7 +1797,7 @@ class ReflectionTest(basetest.TestCase):
# into separate TestCase classes. # into separate TestCase classes.
class TestAllTypesEqualityTest(basetest.TestCase): class TestAllTypesEqualityTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.first_proto = unittest_pb2.TestAllTypes() self.first_proto = unittest_pb2.TestAllTypes()
@ -1813,7 +1813,7 @@ class TestAllTypesEqualityTest(basetest.TestCase):
self.assertEqual(self.first_proto, self.second_proto) self.assertEqual(self.first_proto, self.second_proto)
class FullProtosEqualityTest(basetest.TestCase): class FullProtosEqualityTest(unittest.TestCase):
"""Equality tests using completely-full protos as a starting point.""" """Equality tests using completely-full protos as a starting point."""
@ -1899,7 +1899,7 @@ class FullProtosEqualityTest(basetest.TestCase):
self.assertEqual(self.first_proto, self.second_proto) self.assertEqual(self.first_proto, self.second_proto)
class ExtensionEqualityTest(basetest.TestCase): class ExtensionEqualityTest(unittest.TestCase):
def testExtensionEquality(self): def testExtensionEquality(self):
first_proto = unittest_pb2.TestAllExtensions() first_proto = unittest_pb2.TestAllExtensions()
@ -1932,7 +1932,7 @@ class ExtensionEqualityTest(basetest.TestCase):
self.assertEqual(first_proto, second_proto) self.assertEqual(first_proto, second_proto)
class MutualRecursionEqualityTest(basetest.TestCase): class MutualRecursionEqualityTest(unittest.TestCase):
def testEqualityWithMutualRecursion(self): def testEqualityWithMutualRecursion(self):
first_proto = unittest_pb2.TestMutualRecursionA() first_proto = unittest_pb2.TestMutualRecursionA()
@ -1944,7 +1944,7 @@ class MutualRecursionEqualityTest(basetest.TestCase):
self.assertEqual(first_proto, second_proto) self.assertEqual(first_proto, second_proto)
class ByteSizeTest(basetest.TestCase): class ByteSizeTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.proto = unittest_pb2.TestAllTypes() self.proto = unittest_pb2.TestAllTypes()
@ -2240,7 +2240,7 @@ class ByteSizeTest(basetest.TestCase):
# * Handling of empty submessages (with and without "has" # * Handling of empty submessages (with and without "has"
# bits set). # bits set).
class SerializationTest(basetest.TestCase): class SerializationTest(unittest.TestCase):
def testSerializeEmtpyMessage(self): def testSerializeEmtpyMessage(self):
first_proto = unittest_pb2.TestAllTypes() first_proto = unittest_pb2.TestAllTypes()
@ -2791,7 +2791,7 @@ class SerializationTest(basetest.TestCase):
self.assertEqual(3, proto.repeated_int32[2]) self.assertEqual(3, proto.repeated_int32[2])
class OptionsTest(basetest.TestCase): class OptionsTest(unittest.TestCase):
def testMessageOptions(self): def testMessageOptions(self):
proto = unittest_mset_pb2.TestMessageSet() proto = unittest_mset_pb2.TestMessageSet()
@ -2818,9 +2818,9 @@ class OptionsTest(basetest.TestCase):
class ClassAPITest(basetest.TestCase): class ClassAPITest(unittest.TestCase):
@basetest.unittest.skipIf( @unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2, api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation requires a call to MakeDescriptor()') 'C++ implementation requires a call to MakeDescriptor()')
def testMakeClassWithNestedDescriptor(self): def testMakeClassWithNestedDescriptor(self):
@ -2952,4 +2952,4 @@ class ClassAPITest(basetest.TestCase):
self.assertEqual(msg.bar.baz.deep, 4) self.assertEqual(msg.bar.baz.deep, 4)
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -34,13 +34,14 @@
__author__ = 'petar@google.com (Petar Petrov)' __author__ = 'petar@google.com (Petar Petrov)'
from google.apputils import basetest import unittest
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf import service_reflection from google.protobuf import service_reflection
from google.protobuf import service from google.protobuf import service
class FooUnitTest(basetest.TestCase): class FooUnitTest(unittest.TestCase):
def testService(self): def testService(self):
class MockRpcChannel(service.RpcChannel): class MockRpcChannel(service.RpcChannel):
@ -133,4 +134,4 @@ class FooUnitTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -32,12 +32,13 @@
"""Tests for google.protobuf.symbol_database.""" """Tests for google.protobuf.symbol_database."""
from google.apputils import basetest import unittest
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf import symbol_database from google.protobuf import symbol_database
class SymbolDatabaseTest(basetest.TestCase): class SymbolDatabaseTest(unittest.TestCase):
def _Database(self): def _Database(self):
db = symbol_database.SymbolDatabase() db = symbol_database.SymbolDatabase()
@ -117,4 +118,4 @@ class SymbolDatabaseTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -32,7 +32,8 @@
"""Tests for google.protobuf.text_encoding.""" """Tests for google.protobuf.text_encoding."""
from google.apputils import basetest import unittest
from google.protobuf import text_encoding from google.protobuf import text_encoding
TEST_VALUES = [ TEST_VALUES = [
@ -50,7 +51,7 @@ TEST_VALUES = [
b"\010\011\012\013\014\015")] b"\010\011\012\013\014\015")]
class TextEncodingTestCase(basetest.TestCase): class TextEncodingTestCase(unittest.TestCase):
def testCEscape(self): def testCEscape(self):
for escaped, escaped_utf8, unescaped in TEST_VALUES: for escaped, escaped_utf8, unescaped in TEST_VALUES:
self.assertEquals(escaped, self.assertEquals(escaped,
@ -65,4 +66,4 @@ class TextEncodingTestCase(basetest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
basetest.main() unittest.main()

@ -35,15 +35,15 @@
__author__ = 'kenton@google.com (Kenton Varda)' __author__ = 'kenton@google.com (Kenton Varda)'
import re import re
import unittest
from google.apputils import basetest
from google.protobuf import text_format from google.protobuf import text_format
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
from google.protobuf.internal import test_util from google.protobuf.internal import test_util
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf import unittest_mset_pb2 from google.protobuf import unittest_mset_pb2
class TextFormatTest(basetest.TestCase): class TextFormatTest(unittest.TestCase):
def ReadGolden(self, golden_filename): def ReadGolden(self, golden_filename):
with test_util.GoldenFile(golden_filename) as f: with test_util.GoldenFile(golden_filename) as f:
@ -600,7 +600,7 @@ class TextFormatTest(basetest.TestCase):
self.assertEqual('oneof_uint32', m2.WhichOneof('oneof_field')) self.assertEqual('oneof_uint32', m2.WhichOneof('oneof_field'))
class TokenizerTest(basetest.TestCase): class TokenizerTest(unittest.TestCase):
def testSimpleTokenCases(self): def testSimpleTokenCases(self):
text = ('identifier1:"string1"\n \n\n' text = ('identifier1:"string1"\n \n\n'
@ -745,4 +745,4 @@ class TokenizerTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -35,7 +35,8 @@
__author__ = 'bohdank@google.com (Bohdan Koval)' __author__ = 'bohdank@google.com (Bohdan Koval)'
from google.apputils import basetest import unittest
from google.protobuf import unittest_mset_pb2 from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
@ -45,10 +46,10 @@ from google.protobuf.internal import test_util
from google.protobuf.internal import type_checkers from google.protobuf.internal import type_checkers
@basetest.unittest.skipIf( @unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2, api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation does not expose unknown fields to Python') 'C++ implementation does not expose unknown fields to Python')
class UnknownFieldsTest(basetest.TestCase): class UnknownFieldsTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR self.descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR
@ -179,10 +180,10 @@ class UnknownFieldsTest(basetest.TestCase):
self.assertNotEqual(self.empty_message, message) self.assertNotEqual(self.empty_message, message)
@basetest.unittest.skipIf( @unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2, api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation does not expose unknown fields to Python') 'C++ implementation does not expose unknown fields to Python')
class UnknownEnumValuesTest(basetest.TestCase): class UnknownEnumValuesTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.descriptor = missing_enum_values_pb2.TestEnumValues.DESCRIPTOR self.descriptor = missing_enum_values_pb2.TestEnumValues.DESCRIPTOR
@ -235,4 +236,4 @@ class UnknownEnumValuesTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -34,12 +34,13 @@
__author__ = 'robinson@google.com (Will Robinson)' __author__ = 'robinson@google.com (Will Robinson)'
from google.apputils import basetest import unittest
from google.protobuf import message from google.protobuf import message
from google.protobuf.internal import wire_format from google.protobuf.internal import wire_format
class WireFormatTest(basetest.TestCase): class WireFormatTest(unittest.TestCase):
def testPackTag(self): def testPackTag(self):
field_number = 0xabc field_number = 0xabc
@ -250,4 +251,4 @@ class WireFormatTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -35,19 +35,19 @@
__author__ = 'anuraag@google.com (Anuraag Agrawal)' __author__ = 'anuraag@google.com (Anuraag Agrawal)'
import os import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp'
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2'
# We must set the implementation version above before the google3 imports. # We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace. # Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
from google.protobuf.internal.descriptor_test import * from google.protobuf.internal.descriptor_test import *
class ConfirmCppApi2Test(basetest.TestCase): class ConfirmCppApi2Test(unittest.TestCase):
def testImplementationSetting(self): def testImplementationSetting(self):
self.assertEqual('cpp', api_implementation.Type()) self.assertEqual('cpp', api_implementation.Type())
@ -55,4 +55,4 @@ class ConfirmCppApi2Test(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -33,19 +33,19 @@
"""Tests for google.protobuf.message_factory.""" """Tests for google.protobuf.message_factory."""
import os import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp'
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2'
# We must set the implementation version above before the google3 imports. # We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top # pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace. # Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
from google.protobuf.internal.message_factory_test import * from google.protobuf.internal.message_factory_test import *
class ConfirmCppApi2Test(basetest.TestCase): class ConfirmCppApi2Test(unittest.TestCase):
def testImplementationSetting(self): def testImplementationSetting(self):
self.assertEqual('cpp', api_implementation.Type()) self.assertEqual('cpp', api_implementation.Type())
@ -53,4 +53,4 @@ class ConfirmCppApi2Test(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -36,17 +36,17 @@
__author__ = 'jasonh@google.com (Jason Hsueh)' __author__ = 'jasonh@google.com (Jason Hsueh)'
import os import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp'
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2'
from google.apputils import basetest
from google.protobuf.internal import api_implementation from google.protobuf.internal import api_implementation
from google.protobuf.internal import more_extensions_dynamic_pb2 from google.protobuf.internal import more_extensions_dynamic_pb2
from google.protobuf.internal import more_extensions_pb2 from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal.reflection_test import * from google.protobuf.internal.reflection_test import *
class ReflectionCppTest(basetest.TestCase): class ReflectionCppTest(unittest.TestCase):
def testImplementationSetting(self): def testImplementationSetting(self):
self.assertEqual('cpp', api_implementation.Type()) self.assertEqual('cpp', api_implementation.Type())
self.assertEqual(2, api_implementation.Version()) self.assertEqual(2, api_implementation.Version())
@ -91,4 +91,4 @@ class ReflectionCppTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()

@ -197,11 +197,6 @@ if __name__ == '__main__':
'google.protobuf.text_format'], 'google.protobuf.text_format'],
cmdclass = { 'clean': clean, 'build_py': build_py }, cmdclass = { 'clean': clean, 'build_py': build_py },
install_requires = ['setuptools'], install_requires = ['setuptools'],
# TODO: Restore dependency once a Python 3 compatible google-apputils
# is released.
setup_requires = (['google-apputils']
if sys.version_info[0] < 3 else
[]),
ext_modules = ext_module_list, ext_modules = ext_module_list,
url = 'https://developers.google.com/protocol-buffers/', url = 'https://developers.google.com/protocol-buffers/',
maintainer = maintainer_email, maintainer = maintainer_email,

Loading…
Cancel
Save