aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/internal/reflection_test.py
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2016-04-28 14:34:59 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2016-04-28 14:34:59 -0700
commitcf14183bcd5485b4a71541599ddce0b35eb71352 (patch)
tree12f6e5eb731d7a70cdac4cdafc8b3131629413e2 /python/google/protobuf/internal/reflection_test.py
parentf00300d7f04f1c38a7d70e271f9232b94dd0e326 (diff)
Down integrate from Google internal.
Diffstat (limited to 'python/google/protobuf/internal/reflection_test.py')
-rwxr-xr-xpython/google/protobuf/internal/reflection_test.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/python/google/protobuf/internal/reflection_test.py b/python/google/protobuf/internal/reflection_test.py
index 9e61ea0e..6dc2fffe 100755
--- a/python/google/protobuf/internal/reflection_test.py
+++ b/python/google/protobuf/internal/reflection_test.py
@@ -120,11 +120,13 @@ class ReflectionTest(unittest.TestCase):
proto = unittest_pb2.TestAllTypes(
optional_int32=24,
optional_double=54.321,
- optional_string='optional_string')
+ optional_string='optional_string',
+ optional_float=None)
self.assertEqual(24, proto.optional_int32)
self.assertEqual(54.321, proto.optional_double)
self.assertEqual('optional_string', proto.optional_string)
+ self.assertFalse(proto.HasField("optional_float"))
def testRepeatedScalarConstructor(self):
# Constructor with only repeated scalar types should succeed.
@@ -132,12 +134,14 @@ class ReflectionTest(unittest.TestCase):
repeated_int32=[1, 2, 3, 4],
repeated_double=[1.23, 54.321],
repeated_bool=[True, False, False],
- repeated_string=["optional_string"])
+ repeated_string=["optional_string"],
+ repeated_float=None)
self.assertEqual([1, 2, 3, 4], list(proto.repeated_int32))
self.assertEqual([1.23, 54.321], list(proto.repeated_double))
self.assertEqual([True, False, False], list(proto.repeated_bool))
self.assertEqual(["optional_string"], list(proto.repeated_string))
+ self.assertEqual([], list(proto.repeated_float))
def testRepeatedCompositeConstructor(self):
# Constructor with only repeated composite types should succeed.
@@ -188,7 +192,8 @@ class ReflectionTest(unittest.TestCase):
repeated_foreign_message=[
unittest_pb2.ForeignMessage(c=-43),
unittest_pb2.ForeignMessage(c=45324),
- unittest_pb2.ForeignMessage(c=12)])
+ unittest_pb2.ForeignMessage(c=12)],
+ optional_nested_message=None)
self.assertEqual(24, proto.optional_int32)
self.assertEqual('optional_string', proto.optional_string)
@@ -205,6 +210,7 @@ class ReflectionTest(unittest.TestCase):
unittest_pb2.ForeignMessage(c=45324),
unittest_pb2.ForeignMessage(c=12)],
list(proto.repeated_foreign_message))
+ self.assertFalse(proto.HasField("optional_nested_message"))
def testConstructorTypeError(self):
self.assertRaises(