Commit be89e626 authored by Joshua Haberman's avatar Joshua Haberman

Merge pull request #276 from tamird/drop-apputils-dependency

Migrate Python tests to stdlib unittest, drop apputils dependency.
parents 6003aa1e 9f42f5f4
...@@ -11,9 +11,9 @@ script: ...@@ -11,9 +11,9 @@ script:
- ./autogen.sh && ./configure && make -j2 - ./autogen.sh && ./configure && make -j2
- cd java && mvn test && cd .. - cd java && mvn test && cd ..
- cd javanano && mvn test && cd .. - cd javanano && mvn test && cd ..
- cd python && python setup.py build && python setup.py google_test && cd .. - cd python && python setup.py build && python setup.py test && cd ..
- export LD_LIBRARY_PATH=../src/.libs - export LD_LIBRARY_PATH=../src/.libs
- cd python && python setup.py build --cpp_implementation && python setup.py google_test --cpp_implementation && cd .. - cd python && python setup.py build --cpp_implementation && python setup.py test --cpp_implementation && cd ..
- make distcheck -j2 - make distcheck -j2
notifications: notifications:
email: false email: false
...@@ -207,17 +207,14 @@ python_EXTRA_DIST= \ ...@@ -207,17 +207,14 @@ python_EXTRA_DIST= \
python/google/protobuf/internal/descriptor_pool_test.py \ python/google/protobuf/internal/descriptor_pool_test.py \
python/google/protobuf/internal/descriptor_pool_test1.proto \ python/google/protobuf/internal/descriptor_pool_test1.proto \
python/google/protobuf/internal/descriptor_pool_test2.proto \ python/google/protobuf/internal/descriptor_pool_test2.proto \
python/google/protobuf/internal/descriptor_python_test.py \
python/google/protobuf/internal/descriptor_test.py \ python/google/protobuf/internal/descriptor_test.py \
python/google/protobuf/internal/encoder.py \ python/google/protobuf/internal/encoder.py \
python/google/protobuf/internal/enum_type_wrapper.py \ python/google/protobuf/internal/enum_type_wrapper.py \
python/google/protobuf/internal/factory_test1.proto \ python/google/protobuf/internal/factory_test1.proto \
python/google/protobuf/internal/factory_test2.proto \ python/google/protobuf/internal/factory_test2.proto \
python/google/protobuf/internal/generator_test.py \ python/google/protobuf/internal/generator_test.py \
python/google/protobuf/internal/message_factory_python_test.py \
python/google/protobuf/internal/message_factory_test.py \ python/google/protobuf/internal/message_factory_test.py \
python/google/protobuf/internal/message_listener.py \ python/google/protobuf/internal/message_listener.py \
python/google/protobuf/internal/message_python_test.py \
python/google/protobuf/internal/message_test.py \ python/google/protobuf/internal/message_test.py \
python/google/protobuf/internal/missing_enum_values.proto \ python/google/protobuf/internal/missing_enum_values.proto \
python/google/protobuf/internal/more_extensions.proto \ python/google/protobuf/internal/more_extensions.proto \
......
...@@ -50,21 +50,39 @@ Installation ...@@ -50,21 +50,39 @@ Installation
4) Build and run the tests: 4) Build and run the tests:
$ python setup.py build $ python setup.py build
$ python setup.py google_test $ python setup.py test
To build the C++ implementation run: To build, test, and use the C++ implementation, you must first compile
$ python setup.py build --cpp_implementation libprotobuf.so:
$ (cd .. && make)
On OS X:
If you are running a homebrew-provided python, you must make sure another
version of protobuf is not already installed, as homebrew's python will
search /usr/local/lib for libprotobuf.so before it searches ../src/.libs
You can either unlink homebrew's protobuf or install the libprotobuf you
built earlier:
To test and use the C++ implementation, you must make libprotobuf.so $ brew unlink protobuf
from the C++ build accessible. You can either install the C++ code or
you built, or set LD_LIBRARY_PATH: $ (cd .. && make install)
$ (cd .. && make install) On other *nix:
or
$ export LD_LIBRARY_PATH=../src/.libs You must make libprotobuf.so dynamically available. You can either
install libprotobuf you built earlier, or set LD_LIBRARY_PATH:
$ export LD_LIBRARY_PATH=../src/.libs
or
$ (cd .. && make install)
To build the C++ implementation run:
$ python setup.py build --cpp_implementation
Then run the tests like so: Then run the tests like so:
$ python setup.py google_test --cpp_implementation $ python setup.py test --cpp_implementation
If some tests fail, this library may not work correctly on your If some tests fail, this library may not work correctly on your
system. Continue at your own risk. system. Continue at your own risk.
......
...@@ -152,8 +152,6 @@ import types ...@@ -152,8 +152,6 @@ import types
import unittest import unittest
import uuid import uuid
from google.apputils import basetest
ADDR_RE = re.compile(r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>') ADDR_RE = re.compile(r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>')
_SEPARATOR = uuid.uuid1().hex _SEPARATOR = uuid.uuid1().hex
_FIRST_ARG = object() _FIRST_ARG = object()
...@@ -380,7 +378,7 @@ def _UpdateClassDictForParamTestCase(dct, id_suffix, name, iterator): ...@@ -380,7 +378,7 @@ def _UpdateClassDictForParamTestCase(dct, id_suffix, name, iterator):
id_suffix[new_name] = getattr(func, '__x_extra_id__', '') id_suffix[new_name] = getattr(func, '__x_extra_id__', '')
class ParameterizedTestCase(basetest.TestCase): class ParameterizedTestCase(unittest.TestCase):
"""Base class for test cases using the Parameters decorator.""" """Base class for test cases using the Parameters decorator."""
__metaclass__ = TestGeneratorMetaclass __metaclass__ = TestGeneratorMetaclass
......
...@@ -80,8 +80,8 @@ if _implementation_type != 'python': ...@@ -80,8 +80,8 @@ if _implementation_type != 'python':
# This environment variable can be used to switch between the two # This environment variable can be used to switch between the two
# 'cpp' implementations, overriding the compile-time constants in the # 'cpp' implementations, overriding the compile-time constants in the
# _api_implementation module. Right now only 1 and 2 are valid values. Any other # _api_implementation module. Right now only '2' is supported. Any other
# value will be ignored. # value will cause an error to be raised.
_implementation_version_str = os.getenv( _implementation_version_str = os.getenv(
'PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION', '2') 'PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION', '2')
......
...@@ -34,13 +34,14 @@ ...@@ -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): ...@@ -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)' ...@@ -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 ...@@ -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): ...@@ -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( ...@@ -588,4 +587,4 @@ TEST2_FILE = ProtoFile(
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
#! /usr/bin/python
#
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Unittest for descriptor.py for the pure Python implementation."""
import os
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):
def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type())
if __name__ == '__main__':
basetest.main()
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
__author__ = 'robinson@google.com (Will Robinson)' __author__ = 'robinson@google.com (Will Robinson)'
import sys import sys
import unittest
from google.apputils import basetest
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
...@@ -52,7 +52,7 @@ name: 'TestEmptyMessage' ...@@ -52,7 +52,7 @@ name: 'TestEmptyMessage'
""" """
class DescriptorTest(basetest.TestCase): class DescriptorTest(unittest.TestCase):
def setUp(self): def setUp(self):
file_proto = descriptor_pb2.FileDescriptorProto( file_proto = descriptor_pb2.FileDescriptorProto(
...@@ -390,7 +390,7 @@ class DescriptorTest(basetest.TestCase): ...@@ -390,7 +390,7 @@ class DescriptorTest(basetest.TestCase):
self.assertEqual(self.my_file.name, 'some/filename/some.proto') self.assertEqual(self.my_file.name, 'some/filename/some.proto')
self.assertEqual(self.my_file.package, 'protobuf_unittest') self.assertEqual(self.my_file.package, 'protobuf_unittest')
@basetest.unittest.skipIf( @unittest.skipIf(
api_implementation.Type() != 'cpp' or api_implementation.Version() != 2, api_implementation.Type() != 'cpp' or api_implementation.Version() != 2,
'Immutability of descriptors is only enforced in v2 implementation') 'Immutability of descriptors is only enforced in v2 implementation')
def testImmutableCppDescriptor(self): def testImmutableCppDescriptor(self):
...@@ -403,7 +403,7 @@ class DescriptorTest(basetest.TestCase): ...@@ -403,7 +403,7 @@ class DescriptorTest(basetest.TestCase):
message_descriptor.fields.append(None) message_descriptor.fields.append(None)
class GeneratedDescriptorTest(basetest.TestCase): class GeneratedDescriptorTest(unittest.TestCase):
"""Tests for the properties of descriptors in generated code.""" """Tests for the properties of descriptors in generated code."""
def CheckMessageDescriptor(self, message_descriptor): def CheckMessageDescriptor(self, message_descriptor):
...@@ -493,7 +493,7 @@ class GeneratedDescriptorTest(basetest.TestCase): ...@@ -493,7 +493,7 @@ class GeneratedDescriptorTest(basetest.TestCase):
self.assertEqual('FOO', next(values_iter).name) self.assertEqual('FOO', next(values_iter).name)
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):
...@@ -694,7 +694,7 @@ class DescriptorCopyToProtoTest(basetest.TestCase): ...@@ -694,7 +694,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()
...@@ -776,4 +776,4 @@ class MakeDescriptorTest(basetest.TestCase): ...@@ -776,4 +776,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. ...@@ -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 ...@@ -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'
...@@ -291,7 +292,7 @@ class GeneratorTest(basetest.TestCase): ...@@ -291,7 +292,7 @@ class GeneratorTest(basetest.TestCase):
self.assertIs(desc.oneofs[0], desc.oneofs_by_name['oneof_field']) self.assertIs(desc.oneofs[0], desc.oneofs_by_name['oneof_field'])
nested_names = set(['oneof_uint32', 'oneof_nested_message', nested_names = set(['oneof_uint32', 'oneof_nested_message',
'oneof_string', 'oneof_bytes']) 'oneof_string', 'oneof_bytes'])
self.assertSameElements( self.assertItemsEqual(
nested_names, nested_names,
[field.name for field in desc.oneofs[0].fields]) [field.name for field in desc.oneofs[0].fields])
for field_name, field_desc in desc.fields_by_name.iteritems(): for field_name, field_desc in desc.fields_by_name.iteritems():
...@@ -301,7 +302,7 @@ class GeneratorTest(basetest.TestCase): ...@@ -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): ...@@ -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()
#! /usr/bin/python
#
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests for ..public.message_factory for the pure Python implementation."""
import os
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):
def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type())
if __name__ == '__main__':
basetest.main()
...@@ -34,7 +34,8 @@ ...@@ -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 ...@@ -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): ...@@ -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): ...@@ -128,4 +130,4 @@ class MessageFactoryTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
#! /usr/bin/python
#
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests for ..public.message for the pure Python implementation."""
import os
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):
def testImplementationSetting(self):
self.assertEqual('python', api_implementation.Type())
if __name__ == '__main__':
basetest.main()
...@@ -50,7 +50,6 @@ import pickle ...@@ -50,7 +50,6 @@ import pickle
import sys import sys
import unittest import unittest
from google.apputils import basetest
from google.protobuf.internal import _parameterized from google.protobuf.internal import _parameterized
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2 from google.protobuf import unittest_proto3_arena_pb2
...@@ -75,7 +74,7 @@ def IsNegInf(val): ...@@ -75,7 +74,7 @@ def IsNegInf(val):
@_parameterized.Parameters( @_parameterized.Parameters(
(unittest_pb2), (unittest_pb2),
(unittest_proto3_arena_pb2)) (unittest_proto3_arena_pb2))
class MessageTest(basetest.TestCase): class MessageTest(unittest.TestCase):
def testBadUtf8String(self, message_module): def testBadUtf8String(self, message_module):
if api_implementation.Type() != 'python': if api_implementation.Type() != 'python':
...@@ -887,7 +886,7 @@ class MessageTest(basetest.TestCase): ...@@ -887,7 +886,7 @@ class MessageTest(basetest.TestCase):
# Class to test proto2-only features (required, extensions, etc.) # Class to test proto2-only features (required, extensions, etc.)
class Proto2Test(basetest.TestCase): class Proto2Test(unittest.TestCase):
def testFieldPresence(self): def testFieldPresence(self):
message = unittest_pb2.TestAllTypes() message = unittest_pb2.TestAllTypes()
...@@ -1037,7 +1036,7 @@ class Proto2Test(basetest.TestCase): ...@@ -1037,7 +1036,7 @@ class Proto2Test(basetest.TestCase):
# Class to test proto3-only features/behavior (updated field presence & enums) # Class to test proto3-only features/behavior (updated field presence & enums)
class Proto3Test(basetest.TestCase): class Proto3Test(unittest.TestCase):
def testFieldPresence(self): def testFieldPresence(self):
message = unittest_proto3_arena_pb2.TestAllTypes() message = unittest_proto3_arena_pb2.TestAllTypes()
...@@ -1115,7 +1114,7 @@ class Proto3Test(basetest.TestCase): ...@@ -1115,7 +1114,7 @@ class Proto3Test(basetest.TestCase):
self.assertEqual(7654321, m2.repeated_nested_enum[0]) self.assertEqual(7654321, m2.repeated_nested_enum[0])
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.
...@@ -1138,4 +1137,4 @@ class ValidTypeNamesTest(basetest.TestCase): ...@@ -1138,4 +1137,4 @@ class ValidTypeNamesTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -32,7 +32,7 @@ ...@@ -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 ...@@ -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): ...@@ -74,4 +74,4 @@ class ProtoBuilderTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -39,8 +39,8 @@ import copy ...@@ -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): ...@@ -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): ...@@ -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):
...@@ -1792,7 +1792,7 @@ class ReflectionTest(basetest.TestCase): ...@@ -1792,7 +1792,7 @@ class ReflectionTest(basetest.TestCase):
# Just check the default value. # Just check the default value.
self.assertEqual(57, msg.inner.value) self.assertEqual(57, msg.inner.value)
@basetest.unittest.skipIf( @unittest.skipIf(
api_implementation.Type() != 'cpp' or api_implementation.Version() != 2, api_implementation.Type() != 'cpp' or api_implementation.Version() != 2,
'CPPv2-specific test') 'CPPv2-specific test')
def testBadArguments(self): def testBadArguments(self):
...@@ -1808,7 +1808,7 @@ class ReflectionTest(basetest.TestCase): ...@@ -1808,7 +1808,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()
...@@ -1824,7 +1824,7 @@ class TestAllTypesEqualityTest(basetest.TestCase): ...@@ -1824,7 +1824,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."""
...@@ -1910,7 +1910,7 @@ class FullProtosEqualityTest(basetest.TestCase): ...@@ -1910,7 +1910,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()
...@@ -1943,7 +1943,7 @@ class ExtensionEqualityTest(basetest.TestCase): ...@@ -1943,7 +1943,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()
...@@ -1955,7 +1955,7 @@ class MutualRecursionEqualityTest(basetest.TestCase): ...@@ -1955,7 +1955,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()
...@@ -2251,7 +2251,7 @@ class ByteSizeTest(basetest.TestCase): ...@@ -2251,7 +2251,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()
...@@ -2802,7 +2802,7 @@ class SerializationTest(basetest.TestCase): ...@@ -2802,7 +2802,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()
...@@ -2829,9 +2829,9 @@ class OptionsTest(basetest.TestCase): ...@@ -2829,9 +2829,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):
...@@ -2963,4 +2963,4 @@ class ClassAPITest(basetest.TestCase): ...@@ -2963,4 +2963,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 @@ ...@@ -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): ...@@ -133,4 +134,4 @@ class FooUnitTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -32,12 +32,13 @@ ...@@ -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): ...@@ -117,4 +118,4 @@ class SymbolDatabaseTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -32,7 +32,8 @@ ...@@ -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 = [ ...@@ -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): ...@@ -65,4 +66,4 @@ class TextEncodingTestCase(basetest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
basetest.main() unittest.main()
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
__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.internal import _parameterized from google.protobuf.internal import _parameterized
from google.protobuf import unittest_mset_pb2 from google.protobuf import unittest_mset_pb2
...@@ -47,7 +47,7 @@ from google.protobuf.internal import test_util ...@@ -47,7 +47,7 @@ from google.protobuf.internal import test_util
from google.protobuf import text_format from google.protobuf import text_format
# Base class with some common functionality. # Base class with some common functionality.
class TextFormatBase(basetest.TestCase): class TextFormatBase(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:
...@@ -312,12 +312,12 @@ class TextFormatTest(TextFormatBase): ...@@ -312,12 +312,12 @@ class TextFormatTest(TextFormatBase):
def testParseGroupNotClosed(self, message_module): def testParseGroupNotClosed(self, message_module):
message = message_module.TestAllTypes() message = message_module.TestAllTypes()
text = 'RepeatedGroup: <' text = 'RepeatedGroup: <'
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, '1:16 : Expected ">".', text_format.ParseError, '1:16 : Expected ">".',
text_format.Parse, text, message) text_format.Parse, text, message)
text = 'RepeatedGroup: {' text = 'RepeatedGroup: {'
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, '1:16 : Expected "}".', text_format.ParseError, '1:16 : Expected "}".',
text_format.Parse, text, message) text_format.Parse, text, message)
...@@ -354,7 +354,7 @@ class TextFormatTest(TextFormatBase): ...@@ -354,7 +354,7 @@ class TextFormatTest(TextFormatBase):
def testParseBadIntValue(self, message_module): def testParseBadIntValue(self, message_module):
message = message_module.TestAllTypes() message = message_module.TestAllTypes()
text = 'optional_int32: bork' text = 'optional_int32: bork'
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, text_format.ParseError,
('1:17 : Couldn\'t parse integer: bork'), ('1:17 : Couldn\'t parse integer: bork'),
text_format.Parse, text, message) text_format.Parse, text, message)
...@@ -569,12 +569,12 @@ class Proto2Tests(TextFormatBase): ...@@ -569,12 +569,12 @@ class Proto2Tests(TextFormatBase):
def testParseBadExtension(self): def testParseBadExtension(self):
message = unittest_pb2.TestAllExtensions() message = unittest_pb2.TestAllExtensions()
text = '[unknown_extension]: 8\n' text = '[unknown_extension]: 8\n'
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, text_format.ParseError,
'1:2 : Extension "unknown_extension" not registered.', '1:2 : Extension "unknown_extension" not registered.',
text_format.Parse, text, message) text_format.Parse, text, message)
message = unittest_pb2.TestAllTypes() message = unittest_pb2.TestAllTypes()
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, text_format.ParseError,
('1:2 : Message type "protobuf_unittest.TestAllTypes" does not have ' ('1:2 : Message type "protobuf_unittest.TestAllTypes" does not have '
'extensions.'), 'extensions.'),
...@@ -593,7 +593,7 @@ class Proto2Tests(TextFormatBase): ...@@ -593,7 +593,7 @@ class Proto2Tests(TextFormatBase):
message = unittest_pb2.TestAllExtensions() message = unittest_pb2.TestAllExtensions()
text = ('[protobuf_unittest.optional_int32_extension]: 42 ' text = ('[protobuf_unittest.optional_int32_extension]: 42 '
'[protobuf_unittest.optional_int32_extension]: 67') '[protobuf_unittest.optional_int32_extension]: 67')
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, text_format.ParseError,
('1:96 : Message type "protobuf_unittest.TestAllExtensions" ' ('1:96 : Message type "protobuf_unittest.TestAllExtensions" '
'should not have multiple ' 'should not have multiple '
...@@ -604,7 +604,7 @@ class Proto2Tests(TextFormatBase): ...@@ -604,7 +604,7 @@ class Proto2Tests(TextFormatBase):
message = unittest_pb2.TestAllTypes() message = unittest_pb2.TestAllTypes()
text = ('optional_nested_message { bb: 1 } ' text = ('optional_nested_message { bb: 1 } '
'optional_nested_message { bb: 2 }') 'optional_nested_message { bb: 2 }')
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, text_format.ParseError,
('1:65 : Message type "protobuf_unittest.TestAllTypes.NestedMessage" ' ('1:65 : Message type "protobuf_unittest.TestAllTypes.NestedMessage" '
'should not have multiple "bb" fields.'), 'should not have multiple "bb" fields.'),
...@@ -614,14 +614,14 @@ class Proto2Tests(TextFormatBase): ...@@ -614,14 +614,14 @@ class Proto2Tests(TextFormatBase):
message = unittest_pb2.TestAllTypes() message = unittest_pb2.TestAllTypes()
text = ('optional_int32: 42 ' text = ('optional_int32: 42 '
'optional_int32: 67') 'optional_int32: 67')
self.assertRaisesWithLiteralMatch( self.assertRaisesRegexp(
text_format.ParseError, text_format.ParseError,
('1:36 : Message type "protobuf_unittest.TestAllTypes" should not ' ('1:36 : Message type "protobuf_unittest.TestAllTypes" should not '
'have multiple "optional_int32" fields.'), 'have multiple "optional_int32" fields.'),
text_format.Parse, text, message) text_format.Parse, text, message)
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'
...@@ -766,4 +766,4 @@ class TokenizerTest(basetest.TestCase): ...@@ -766,4 +766,4 @@ class TokenizerTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -35,7 +35,8 @@ ...@@ -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 import unittest_proto3_arena_pb2 from google.protobuf import unittest_proto3_arena_pb2
...@@ -46,7 +47,7 @@ from google.protobuf.internal import test_util ...@@ -46,7 +47,7 @@ from google.protobuf.internal import test_util
from google.protobuf.internal import type_checkers from google.protobuf.internal import type_checkers
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
...@@ -104,7 +105,7 @@ class UnknownFieldsTest(basetest.TestCase): ...@@ -104,7 +105,7 @@ class UnknownFieldsTest(basetest.TestCase):
# fields when checking equality. # fields when checking equality.
# #
# TODO(haberman): fix this. # TODO(haberman): fix this.
@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')
def testEquals(self): def testEquals(self):
...@@ -117,10 +118,10 @@ class UnknownFieldsTest(basetest.TestCase): ...@@ -117,10 +118,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 UnknownFieldsAccessorsTest(basetest.TestCase): class UnknownFieldsAccessorsTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR self.descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR
...@@ -205,10 +206,10 @@ class UnknownFieldsAccessorsTest(basetest.TestCase): ...@@ -205,10 +206,10 @@ class UnknownFieldsAccessorsTest(basetest.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 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
...@@ -261,4 +262,4 @@ class UnknownEnumValuesTest(basetest.TestCase): ...@@ -261,4 +262,4 @@ class UnknownEnumValuesTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -34,12 +34,13 @@ ...@@ -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): ...@@ -250,4 +251,4 @@ class WireFormatTest(basetest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
...@@ -155,7 +155,7 @@ if __name__ == '__main__': ...@@ -155,7 +155,7 @@ if __name__ == '__main__':
"google/protobuf/pyext/repeated_scalar_container.cc", "google/protobuf/pyext/repeated_scalar_container.cc",
"google/protobuf/pyext/repeated_composite_container.cc" ], "google/protobuf/pyext/repeated_composite_container.cc" ],
define_macros=[('GOOGLE_PROTOBUF_HAS_ONEOF', '1')], define_macros=[('GOOGLE_PROTOBUF_HAS_ONEOF', '1')],
include_dirs = [ ".", "..", "../src"], include_dirs = [ ".", "../src" ],
libraries = [ "protobuf" ], libraries = [ "protobuf" ],
library_dirs = [ '../src/.libs' ], library_dirs = [ '../src/.libs' ],
)) ))
...@@ -165,7 +165,7 @@ if __name__ == '__main__': ...@@ -165,7 +165,7 @@ if __name__ == '__main__':
version = GetVersion(), version = GetVersion(),
packages = [ 'google' ], packages = [ 'google' ],
namespace_packages = [ 'google' ], namespace_packages = [ 'google' ],
google_test_dir = "google/protobuf/internal", test_suite = 'google.protobuf.internal',
# Must list modules explicitly so that we don't install tests. # Must list modules explicitly so that we don't install tests.
py_modules = [ py_modules = [
'google.protobuf.internal.api_implementation', 'google.protobuf.internal.api_implementation',
...@@ -194,11 +194,6 @@ if __name__ == '__main__': ...@@ -194,11 +194,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,
......
...@@ -32,11 +32,12 @@ ...@@ -32,11 +32,12 @@
"""Negative compilation unit tests for arena API.""" """Negative compilation unit tests for arena API."""
import unittest
from google3.testing.pybase import fake_target_util from google3.testing.pybase import fake_target_util
from google.apputils import basetest
class ArenaNcTest(basetest.TestCase): class ArenaNcTest(unittest.TestCase):
def testCompilerErrors(self): def testCompilerErrors(self):
"""Runs a list of tests to verify compiler error messages.""" """Runs a list of tests to verify compiler error messages."""
...@@ -56,4 +57,4 @@ class ArenaNcTest(basetest.TestCase): ...@@ -56,4 +57,4 @@ class ArenaNcTest(basetest.TestCase):
) )
if __name__ == '__main__': if __name__ == '__main__':
basetest.main() unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment