aboutsummaryrefslogtreecommitdiffhomepage
path: root/python
diff options
context:
space:
mode:
authorGravatar Dan O'Reilly <oreilldf@gmail.com>2015-08-13 01:17:26 -0400
committerGravatar Dan O'Reilly <oreilldf@gmail.com>2015-08-13 01:17:26 -0400
commit833c046fb703f9c5ef6bd8b05c4aa1d7e2ecec0e (patch)
treecb46803a7135ec6fc4b9a7b3f695d98d7c0b4fa7 /python
parente47cdd5a559f488ba52756927ce68f4cf93874fa (diff)
Fixing some tests
Signed-off-by: Dan O'Reilly <oreilldf@gmail.com>
Diffstat (limited to 'python')
-rwxr-xr-xpython/google/protobuf/internal/_parameterized.py10
-rwxr-xr-xpython/google/protobuf/internal/python_message.py3
-rwxr-xr-xpython/google/protobuf/internal/reflection_test.py2
-rwxr-xr-xpython/setup.py57
4 files changed, 30 insertions, 42 deletions
diff --git a/python/google/protobuf/internal/_parameterized.py b/python/google/protobuf/internal/_parameterized.py
index 400b2216..3002b230 100755
--- a/python/google/protobuf/internal/_parameterized.py
+++ b/python/google/protobuf/internal/_parameterized.py
@@ -152,6 +152,8 @@ import types
import unittest
import uuid
+import six
+
ADDR_RE = re.compile(r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>')
_SEPARATOR = uuid.uuid1().hex
_FIRST_ARG = object()
@@ -170,13 +172,13 @@ def _StrClass(cls):
def _NonStringIterable(obj):
return (isinstance(obj, collections.Iterable) and not
- isinstance(obj, basestring))
+ isinstance(obj, six.string_types))
def _FormatParameterList(testcase_params):
if isinstance(testcase_params, collections.Mapping):
return ', '.join('%s=%s' % (argname, _CleanRepr(value))
- for argname, value in testcase_params.iteritems())
+ for argname, value in testcase_params.items())
elif _NonStringIterable(testcase_params):
return ', '.join(map(_CleanRepr, testcase_params))
else:
@@ -258,7 +260,7 @@ def _ModifyClass(class_object, testcases, naming_type):
'Cannot add parameters to %s,'
' which already has parameterized methods.' % (class_object,))
class_object._id_suffix = id_suffix = {}
- for name, obj in class_object.__dict__.items():
+ for name, obj in class_object.__dict__.copy().items():
if (name.startswith(unittest.TestLoader.testMethodPrefix)
and isinstance(obj, types.FunctionType)):
delattr(class_object, name)
@@ -266,7 +268,7 @@ def _ModifyClass(class_object, testcases, naming_type):
_UpdateClassDictForParamTestCase(
methods, id_suffix, name,
_ParameterizedTestIter(obj, testcases, naming_type))
- for name, meth in methods.iteritems():
+ for name, meth in methods.items():
setattr(class_object, name, meth)
diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py
index bb06beb3..9a72315e 100755
--- a/python/google/protobuf/internal/python_message.py
+++ b/python/google/protobuf/internal/python_message.py
@@ -59,7 +59,6 @@ import weakref
import six
import six.moves.copyreg as copyreg
-import six.string_types
# We use "as" to avoid name collisions with variables.
from google.protobuf.internal import containers
@@ -1120,7 +1119,7 @@ def _AddIsInitializedMethod(message_descriptor, cls):
# ScalarMaps can't have any initialization errors.
pass
elif field.label == _FieldDescriptor.LABEL_REPEATED:
- for i in xrange(len(value)):
+ for i in range(len(value)):
element = value[i]
prefix = "%s[%d]." % (name, i)
sub_errors = element.FindInitializationErrors()
diff --git a/python/google/protobuf/internal/reflection_test.py b/python/google/protobuf/internal/reflection_test.py
index 794395c5..d1c18c1f 100755
--- a/python/google/protobuf/internal/reflection_test.py
+++ b/python/google/protobuf/internal/reflection_test.py
@@ -1634,7 +1634,7 @@ class ReflectionTest(unittest.TestCase):
self.assertFalse(proto.IsInitialized(errors))
self.assertEqual(errors, ['a', 'b', 'c'])
- @basetest.unittest.skipIf(
+ @skipIf(
api_implementation.Type() != 'cpp' or api_implementation.Version() != 2,
'Errors are only available from the most recent C++ implementation.')
def testFileDescriptorErrors(self):
diff --git a/python/setup.py b/python/setup.py
index ba0dac2c..bb8a7d05 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -88,41 +88,27 @@ def generate_proto(source, require = True):
sys.exit(-1)
def GenerateUnittestProtos():
- generate_proto("../src/google/protobuf/unittest.proto")
- generate_proto("../src/google/protobuf/unittest_custom_options.proto")
- generate_proto("../src/google/protobuf/unittest_import.proto")
- generate_proto("../src/google/protobuf/unittest_import_public.proto")
- generate_proto("../src/google/protobuf/unittest_mset.proto")
- generate_proto("../src/google/protobuf/unittest_no_generic_services.proto")
- generate_proto("google/protobuf/internal/descriptor_pool_test1.proto")
- generate_proto("google/protobuf/internal/descriptor_pool_test2.proto")
- generate_proto("google/protobuf/internal/test_bad_identifiers.proto")
- generate_proto("google/protobuf/internal/missing_enum_values.proto")
- generate_proto("google/protobuf/internal/more_extensions.proto")
- generate_proto("google/protobuf/internal/more_extensions_dynamic.proto")
- generate_proto("google/protobuf/internal/more_messages.proto")
- generate_proto("google/protobuf/internal/factory_test1.proto")
- generate_proto("google/protobuf/internal/factory_test2.proto")
- generate_proto("google/protobuf/internal/import_test_package/inner.proto")
- generate_proto("google/protobuf/internal/import_test_package/outer.proto")
- generate_proto("google/protobuf/pyext/python.proto")
-
-def MakeTestSuite():
- # Test C++ implementation
- import unittest
- import google.protobuf.pyext.descriptor_cpp2_test as descriptor_cpp2_test
- import google.protobuf.pyext.message_factory_cpp2_test \
- as message_factory_cpp2_test
- import google.protobuf.pyext.reflection_cpp2_generated_test \
- as reflection_cpp2_generated_test
-
- loader = unittest.defaultTestLoader
- suite = unittest.TestSuite()
- for test in [ descriptor_cpp2_test,
- message_factory_cpp2_test,
- reflection_cpp2_generated_test]:
- suite.addTest(loader.loadTestsFromModule(test))
- return suite
+ generate_proto("../src/google/protobuf/map_unittest.proto", False)
+ generate_proto("../src/google/protobuf/unittest.proto", False)
+ generate_proto("../src/google/protobuf/unittest_custom_options.proto", False)
+ generate_proto("../src/google/protobuf/unittest_import.proto", False)
+ generate_proto("../src/google/protobuf/unittest_import_public.proto", False)
+ generate_proto("../src/google/protobuf/unittest_mset.proto", False)
+ generate_proto("../src/google/protobuf/unittest_no_generic_services.proto", False)
+ generate_proto("../src/google/protobuf/unittest_proto3_arena.proto", False)
+ generate_proto("google/protobuf/internal/descriptor_pool_test1.proto", False)
+ generate_proto("google/protobuf/internal/descriptor_pool_test2.proto", False)
+ generate_proto("google/protobuf/internal/factory_test1.proto", False)
+ generate_proto("google/protobuf/internal/factory_test2.proto", False)
+ generate_proto("google/protobuf/internal/import_test_package/inner.proto", False)
+ generate_proto("google/protobuf/internal/import_test_package/outer.proto", False)
+ generate_proto("google/protobuf/internal/missing_enum_values.proto", False)
+ generate_proto("google/protobuf/internal/more_extensions.proto", False)
+ generate_proto("google/protobuf/internal/more_extensions_dynamic.proto", False)
+ generate_proto("google/protobuf/internal/more_messages.proto", False)
+ generate_proto("google/protobuf/internal/test_bad_identifiers.proto", False)
+ generate_proto("google/protobuf/pyext/python.proto", False)
+
class clean(_clean):
def run(self):
@@ -153,6 +139,7 @@ class build_py(_build_py):
# _build_py is an old-style class, so super() doesn't work.
_build_py.run(self)
+
if __name__ == '__main__':
ext_module_list = []
cpp_impl = '--cpp_implementation'