aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jie Luo <anandolee@gmail.com>2017-08-07 11:04:09 -0700
committerGravatar GitHub <noreply@github.com>2017-08-07 11:04:09 -0700
commitfae381693f029da1456f6e90f91fe995723163f3 (patch)
treeca1ce36ab5bbd23c613966f69d54842491ca0b8c
parentd08c291ac7b555cf5090481fa7a009fb5dc5d804 (diff)
parentf5817b3056b1ef115a98909d75e54b7a5815a954 (diff)
Merge pull request #3454 from anandolee/master
Add python 2.6 test back for cpp implementation.
-rw-r--r--python/google/protobuf/internal/message_factory_test.py9
-rwxr-xr-xpython/google/protobuf/internal/message_test.py5
-rwxr-xr-xpython/google/protobuf/internal/reflection_test.py7
-rwxr-xr-xtests.sh3
4 files changed, 16 insertions, 8 deletions
diff --git a/python/google/protobuf/internal/message_factory_test.py b/python/google/protobuf/internal/message_factory_test.py
index 4caa2443..aa7af2d0 100644
--- a/python/google/protobuf/internal/message_factory_test.py
+++ b/python/google/protobuf/internal/message_factory_test.py
@@ -183,7 +183,14 @@ class MessageFactoryTest(unittest.TestCase):
with self.assertRaises(Exception) as cm:
factory.GetMessages([f.name])
- self.assertIsInstance(cm.exception, (AssertionError, ValueError))
+ self.assertIn(str(cm.exception),
+ ['Extensions '
+ '"google.protobuf.python.internal.Duplicate.extension_field" and'
+ ' "google.protobuf.python.internal.Extension.extension_field"'
+ ' both try to extend message type'
+ ' "google.protobuf.python.internal.Container"'
+ ' with field number 2.',
+ 'Double registration of Extensions'])
if __name__ == '__main__':
diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py
index e8b794f0..f11bb6d6 100755
--- a/python/google/protobuf/internal/message_test.py
+++ b/python/google/protobuf/internal/message_test.py
@@ -1832,8 +1832,9 @@ class PackedFieldTest(BaseTestCase):
self.assertEqual(golden_data, message.SerializeToString())
-@unittest.skipIf(api_implementation.Type() != 'cpp',
- 'explicit tests of the C++ implementation')
+@unittest.skipIf(api_implementation.Type() != 'cpp' or
+ sys.version_info < (2, 7),
+ 'explicit tests of the C++ implementation for PY27 and above')
class OversizeProtosTest(BaseTestCase):
@classmethod
diff --git a/python/google/protobuf/internal/reflection_test.py b/python/google/protobuf/internal/reflection_test.py
index 55b0d72e..5ab5225e 100755
--- a/python/google/protobuf/internal/reflection_test.py
+++ b/python/google/protobuf/internal/reflection_test.py
@@ -40,6 +40,7 @@ import gc
import operator
import six
import struct
+import sys
try:
import unittest2 as unittest #PY26
@@ -686,8 +687,8 @@ class ReflectionTest(BaseTestCase):
self.assertEqual(expected_min, getattr(pb, field_name))
setattr(pb, field_name, expected_max)
self.assertEqual(expected_max, getattr(pb, field_name))
- self.assertRaises(ValueError, setattr, pb, field_name, expected_min - 1)
- self.assertRaises(ValueError, setattr, pb, field_name, expected_max + 1)
+ self.assertRaises(Exception, setattr, pb, field_name, expected_min - 1)
+ self.assertRaises(Exception, setattr, pb, field_name, expected_max + 1)
TestMinAndMaxIntegers('optional_int32', -(1 << 31), (1 << 31) - 1)
TestMinAndMaxIntegers('optional_uint32', 0, 0xffffffff)
@@ -696,7 +697,7 @@ class ReflectionTest(BaseTestCase):
# A bit of white-box testing since -1 is an int and not a long in C++ and
# so goes down a different path.
pb = unittest_pb2.TestAllTypes()
- with self.assertRaises(ValueError):
+ with self.assertRaises(Exception):
pb.optional_uint64 = integer_fn(-(1 << 63))
pb = unittest_pb2.TestAllTypes()
diff --git a/tests.sh b/tests.sh
index cfc08c35..f68de059 100755
--- a/tests.sh
+++ b/tests.sh
@@ -294,8 +294,7 @@ build_python_cpp() {
cd python
# Only test Python 2.6/3.x on Linux
if [ $(uname -s) == "Linux" ]; then
- # py26 is currently disabled due to json_format
- envlist=py\{27,33,34\}-cpp
+ envlist=py\{26,27,33,34\}-cpp
else
envlist=py27-cpp
fi