Make Python 3 pass all unit tests
This commit is contained in:
parent
814c858f3f
commit
0d931d9c8f
|
|
@ -41,9 +41,10 @@ py_library(
|
|||
py_library(
|
||||
name = "logging_pool",
|
||||
srcs = ["logging_pool.py"],
|
||||
deps = [
|
||||
requirement("futures"),
|
||||
],
|
||||
deps = select({
|
||||
"//conditions:default": [requirement('futures'),],
|
||||
"//:python3": [],
|
||||
}),
|
||||
)
|
||||
|
||||
py_library(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ class ChannelTest(unittest.TestCase):
|
|||
channel = grpc.secure_channel('google.com:443', channel_credentials)
|
||||
channel.close()
|
||||
|
||||
print("HELLO", "WORLD", end='!\n')
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig()
|
||||
|
|
|
|||
Loading…
Reference in New Issue