Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on 'google.apputils'. #165

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@

import os
import sys
import unittest
# Clear environment implementation settings before the google3 imports.
os.environ.pop('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION', None)
os.environ.pop('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION', None)

# pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation


class ApiImplementationDefaultTest(basetest.TestCase):
class ApiImplementationDefaultTest(unittest.TestCase):

if sys.version_info.major <= 2:

Expand All @@ -60,4 +60,4 @@ def testThatCppApiV2IsTheDefault(self):


if __name__ == '__main__':
basetest.main()
unittest.main()
7 changes: 4 additions & 3 deletions python/google/protobuf/internal/descriptor_database_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@

__author__ = '[email protected] (Matt Toia)'

from google.apputils import basetest
import unittest

from google.protobuf import descriptor_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf import descriptor_database


class DescriptorDatabaseTest(basetest.TestCase):
class DescriptorDatabaseTest(unittest.TestCase):

def testAdd(self):
db = descriptor_database.DescriptorDatabase()
Expand All @@ -62,4 +63,4 @@ def testAdd(self):
'google.protobuf.python.internal.MessageWithNestedEnumOnly.NestedEnum'))

if __name__ == '__main__':
basetest.main()
unittest.main()
7 changes: 3 additions & 4 deletions python/google/protobuf/internal/descriptor_pool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import os
import unittest

from google.apputils import basetest
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
Expand All @@ -51,7 +50,7 @@
from google.protobuf import symbol_database


class DescriptorPoolTest(basetest.TestCase):
class DescriptorPoolTest(unittest.TestCase):

def setUp(self):
self.pool = descriptor_pool.DescriptorPool()
Expand Down Expand Up @@ -426,7 +425,7 @@ def CheckField(self, test, msg_desc, name, index):
test.assertEqual(self.extended_type, field_desc.containing_type.name)


class AddDescriptorTest(basetest.TestCase):
class AddDescriptorTest(unittest.TestCase):

def _TestMessage(self, prefix):
pool = descriptor_pool.DescriptorPool()
Expand Down Expand Up @@ -588,4 +587,4 @@ def testFile(self):


if __name__ == '__main__':
basetest.main()
unittest.main()
6 changes: 3 additions & 3 deletions python/google/protobuf/internal/descriptor_python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
"""Unittest for descriptor.py for the pure Python implementation."""

import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'

# We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import
from google.protobuf.internal.descriptor_test import *


class ConfirmPurePythonTest(basetest.TestCase):
class ConfirmPurePythonTest(unittest.TestCase):

def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type())


if __name__ == '__main__':
basetest.main()
unittest.main()
11 changes: 6 additions & 5 deletions python/google/protobuf/internal/descriptor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

__author__ = '[email protected] (Will Robinson)'

from google.apputils import basetest
import unittest

from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_pb2
Expand All @@ -48,7 +49,7 @@
"""


class DescriptorTest(basetest.TestCase):
class DescriptorTest(unittest.TestCase):

def setUp(self):
self.my_file = descriptor.FileDescriptor(
Expand Down Expand Up @@ -395,7 +396,7 @@ def testFileDescriptor(self):
self.assertEqual(self.my_file.package, 'protobuf_unittest')


class DescriptorCopyToProtoTest(basetest.TestCase):
class DescriptorCopyToProtoTest(unittest.TestCase):
"""Tests for CopyTo functions of Descriptor."""

def _AssertProtoEqual(self, actual_proto, expected_class, expected_ascii):
Expand Down Expand Up @@ -594,7 +595,7 @@ def testCopyToProto_ServiceDescriptor(self):
TEST_SERVICE_ASCII)


class MakeDescriptorTest(basetest.TestCase):
class MakeDescriptorTest(unittest.TestCase):

def testMakeDescriptorWithNestedFields(self):
file_descriptor_proto = descriptor_pb2.FileDescriptorProto()
Expand Down Expand Up @@ -676,4 +677,4 @@ def testMakeDescriptorWithOptions(self):
options.Extensions[unittest_custom_options_pb2.msgopt].i)

if __name__ == '__main__':
basetest.main()
unittest.main()
9 changes: 5 additions & 4 deletions python/google/protobuf/internal/generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

__author__ = '[email protected] (Will Robinson)'

from google.apputils import basetest
import unittest

from google.protobuf.internal import test_bad_identifiers_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2
Expand All @@ -55,7 +56,7 @@
MAX_EXTENSION = 536870912


class GeneratorTest(basetest.TestCase):
class GeneratorTest(unittest.TestCase):

def testNestedMessageDescriptor(self):
field_name = 'optional_nested_message'
Expand Down Expand Up @@ -301,7 +302,7 @@ def testOneof(self):
self.assertIsNone(field_desc.containing_oneof)


class SymbolDatabaseRegistrationTest(basetest.TestCase):
class SymbolDatabaseRegistrationTest(unittest.TestCase):
"""Checks that messages, enums and files are correctly registered."""

def testGetSymbol(self):
Expand Down Expand Up @@ -340,4 +341,4 @@ def testFindFileByName(self):
'google/protobuf/unittest.proto').name)

if __name__ == '__main__':
basetest.main()
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
"""Tests for ..public.message_factory for the pure Python implementation."""

import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'

# We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import
from google.protobuf.internal.message_factory_test import *


class ConfirmPurePythonTest(basetest.TestCase):
class ConfirmPurePythonTest(unittest.TestCase):

def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type())


if __name__ == '__main__':
basetest.main()
unittest.main()
26 changes: 14 additions & 12 deletions python/google/protobuf/internal/message_factory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

__author__ = '[email protected] (Matt Toia)'

from google.apputils import basetest
import unittest

from google.protobuf import descriptor_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
Expand All @@ -43,7 +44,7 @@
from google.protobuf import message_factory


class MessageFactoryTest(basetest.TestCase):
class MessageFactoryTest(unittest.TestCase):

def setUp(self):
self.factory_test1_fd = descriptor_pb2.FileDescriptorProto.FromString(
Expand Down Expand Up @@ -104,17 +105,18 @@ def testGetMessages(self):
for _ in range(2):
messages = message_factory.GetMessages([self.factory_test2_fd,
self.factory_test1_fd])
self.assertContainsSubset(
['google.protobuf.python.internal.Factory2Message',
'google.protobuf.python.internal.Factory1Message'],
messages.keys())
self.assertTrue(
set(['google.protobuf.python.internal.Factory2Message',
'google.protobuf.python.internal.Factory1Message'],
).issubset(set(messages.keys())))
self._ExerciseDynamicClass(
messages['google.protobuf.python.internal.Factory2Message'])
self.assertContainsSubset(
['google.protobuf.python.internal.Factory2Message.one_more_field',
'google.protobuf.python.internal.another_field'],
(messages['google.protobuf.python.internal.Factory1Message']
._extensions_by_name.keys()))
self.assertTrue(
set(['google.protobuf.python.internal.Factory2Message.one_more_field',
'google.protobuf.python.internal.another_field'],
).issubset(
set(messages['google.protobuf.python.internal.Factory1Message']
._extensions_by_name.keys())))
factory_msg1 = messages['google.protobuf.python.internal.Factory1Message']
msg1 = messages['google.protobuf.python.internal.Factory1Message']()
ext1 = factory_msg1._extensions_by_name[
Expand All @@ -128,4 +130,4 @@ def testGetMessages(self):


if __name__ == '__main__':
basetest.main()
unittest.main()
6 changes: 3 additions & 3 deletions python/google/protobuf/internal/message_python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
"""Tests for ..public.message for the pure Python implementation."""

import os
import unittest
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'

# We must set the implementation version above before the google3 imports.
# pylint: disable=g-import-not-at-top
from google.apputils import basetest
from google.protobuf.internal import api_implementation
# Run all tests from the original module by putting them in our namespace.
# pylint: disable=wildcard-import
from google.protobuf.internal.message_test import *


class ConfirmPurePythonTest(basetest.TestCase):
class ConfirmPurePythonTest(unittest.TestCase):

def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type())


if __name__ == '__main__':
basetest.main()
unittest.main()
8 changes: 4 additions & 4 deletions python/google/protobuf/internal/message_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import operator
import pickle
import sys
import unittest

from google.apputils import basetest
from google.protobuf import unittest_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import test_util
Expand All @@ -69,7 +69,7 @@ def IsNegInf(val):
return isinf(val) and (val < 0)


class MessageTest(basetest.TestCase):
class MessageTest(unittest.TestCase):

def testBadUtf8String(self):
if api_implementation.Type() != 'python':
Expand Down Expand Up @@ -695,7 +695,7 @@ def testHasFieldOnRepeatedField(self):
m.HasField('repeated_int32')


class ValidTypeNamesTest(basetest.TestCase):
class ValidTypeNamesTest(unittest.TestCase):

def assertImportFromName(self, msg, base_name):
# Parse <type 'module.class_name'> to extra 'some.name' as a string.
Expand All @@ -718,4 +718,4 @@ def testTypeNamesCanBeImported(self):


if __name__ == '__main__':
basetest.main()
unittest.main()
6 changes: 3 additions & 3 deletions python/google/protobuf/internal/proto_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@

"""Tests for google.protobuf.proto_builder."""

from google.apputils import basetest
import unittest

from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import proto_builder
from google.protobuf import text_format


class ProtoBuilderTest(basetest.TestCase):
class ProtoBuilderTest(unittest.TestCase):

def setUp(self):
self._fields = {
Expand Down Expand Up @@ -74,4 +74,4 @@ def testMakeSameProtoClassTwice(self):


if __name__ == '__main__':
basetest.main()
unittest.main()
Loading