Revert the compare of protobuf message to comparing encoded result

pull/17644/head
Lidi Zheng 6 years ago
parent 15be9de11b
commit 222db62721
  1. 20
      src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py

@ -50,6 +50,16 @@ def _file_descriptor_to_proto(descriptor):
class ReflectionServicerTest(unittest.TestCase):
# NOTE(lidiz) Bazel + Python 3 will result in creating two different
# instance of DESCRIPTOR for each message. So, the equal comparision
# between protobuf returned by stub and manually crafted protobuf will
# always fail.
def _assert_sequence_of_proto_equal(self, x, y):
self.assertSequenceEqual(
list(map(lambda x: x.SerializeToString(), x)),
list(map(lambda x: x.SerializeToString(), y)),
)
def setUp(self):
self._server = test_common.test_server()
reflection.enable_server_reflection(_SERVICE_NAMES, self._server)
@ -84,7 +94,7 @@ class ReflectionServicerTest(unittest.TestCase):
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
)),
)
self.assertSequenceEqual(expected_responses, responses)
self._assert_sequence_of_proto_equal(expected_responses, responses)
def testFileBySymbol(self):
requests = (
@ -108,7 +118,7 @@ class ReflectionServicerTest(unittest.TestCase):
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
)),
)
self.assertSequenceEqual(expected_responses, responses)
self._assert_sequence_of_proto_equal(expected_responses, responses)
def testFileContainingExtension(self):
requests = (
@ -137,7 +147,7 @@ class ReflectionServicerTest(unittest.TestCase):
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
)),
)
self.assertSequenceEqual(expected_responses, responses)
self._assert_sequence_of_proto_equal(expected_responses, responses)
def testExtensionNumbersOfType(self):
requests = (
@ -162,7 +172,7 @@ class ReflectionServicerTest(unittest.TestCase):
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
)),
)
self.assertSequenceEqual(expected_responses, responses)
self._assert_sequence_of_proto_equal(expected_responses, responses)
def testListServices(self):
requests = (reflection_pb2.ServerReflectionRequest(list_services='',),)
@ -173,7 +183,7 @@ class ReflectionServicerTest(unittest.TestCase):
service=tuple(
reflection_pb2.ServiceResponse(name=name)
for name in _SERVICE_NAMES))),)
self.assertSequenceEqual(expected_responses, responses)
self._assert_sequence_of_proto_equal(expected_responses, responses)
def testReflectionServiceName(self):
self.assertEqual(reflection.SERVICE_NAME,

Loading…
Cancel
Save