From 471ff7727031d7ca17c62f34c38314758142393e Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Tue, 27 Aug 2024 14:23:00 -0700 Subject: [PATCH] Remove deprecated service.py usages from test PiperOrigin-RevId: 668137152 --- python/google/protobuf/internal/generator_test.py | 7 ------- .../google/protobuf/internal/service_reflection_test.py | 9 +++++---- python/google/protobuf/service.py | 8 ++++---- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/python/google/protobuf/internal/generator_test.py b/python/google/protobuf/internal/generator_test.py index d11cb8d033350..0f4ad64620de9 100644 --- a/python/google/protobuf/internal/generator_test.py +++ b/python/google/protobuf/internal/generator_test.py @@ -19,7 +19,6 @@ import unittest from google.protobuf.internal import test_bad_identifiers_pb2 -from google.protobuf import service from google.protobuf import symbol_database from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_import_public_pb2 @@ -283,12 +282,6 @@ def testNoGenericServices(self): self.assertTrue(hasattr(unittest_no_generic_services_pb2, "FOO")) self.assertTrue(hasattr(unittest_no_generic_services_pb2, "test_extension")) - # Make sure unittest_no_generic_services_pb2 has no services subclassing - # Proto2 Service class. - if hasattr(unittest_no_generic_services_pb2, "TestService"): - self.assertFalse(issubclass(unittest_no_generic_services_pb2.TestService, - service.Service)) - def testMessageTypesByName(self): file_type = unittest_pb2.DESCRIPTOR self.assertEqual( diff --git a/python/google/protobuf/internal/service_reflection_test.py b/python/google/protobuf/internal/service_reflection_test.py index 1a809d5e39688..ca9e70a3807ad 100644 --- a/python/google/protobuf/internal/service_reflection_test.py +++ b/python/google/protobuf/internal/service_reflection_test.py @@ -13,21 +13,21 @@ import unittest from google.protobuf import service_reflection -from google.protobuf import service from google.protobuf import unittest_pb2 class FooUnitTest(unittest.TestCase): def testService(self): - class MockRpcChannel(service.RpcChannel): + + class MockRpcChannel: def CallMethod(self, method, controller, request, response, callback): self.method = method self.controller = controller self.request = request callback(response) - class MockRpcController(service.RpcController): + class MockRpcController: def SetFailed(self, msg): self.failure_message = msg @@ -81,7 +81,8 @@ def Bar(self, rpc_controller, request, done): self.assertEqual(True, srvc.bar_called) def testServiceStub(self): - class MockRpcChannel(service.RpcChannel): + + class MockRpcChannel: def CallMethod(self, method, controller, request, response_class, callback): self.method = method diff --git a/python/google/protobuf/service.py b/python/google/protobuf/service.py index 38b8217919cbf..8002c040ffd9b 100644 --- a/python/google/protobuf/service.py +++ b/python/google/protobuf/service.py @@ -70,12 +70,12 @@ def CallMethod(self, method_descriptor, rpc_controller, Postconditions: * "done" will be called when the method is complete. This may be - before CallMethod() returns or it may be at some point in the future. + before CallMethod() returns or it may be at some point in the future. * If the RPC failed, the response value passed to "done" will be None. - Further details about the failure can be found by querying the - RpcController. + Further details about the failure can be found by querying the + RpcController. """ - raise NotImplementedError + raise NotImplementedError def GetRequestClass(self, method_descriptor): """Returns the class of the request message for the specified method.