Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove deprecated service.py usages from test". For 29.x only #19434

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python/google/protobuf/internal/generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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
Expand Down Expand Up @@ -282,6 +283,12 @@ 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(
Expand Down
9 changes: 4 additions & 5 deletions python/google/protobuf/internal/service_reflection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
class MockRpcChannel(service.RpcChannel):
def CallMethod(self, method, controller, request, response, callback):
self.method = method
self.controller = controller
self.request = request
callback(response)

class MockRpcController:
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
self.failure_message = msg

Expand Down Expand Up @@ -81,8 +81,7 @@ def Bar(self, rpc_controller, request, done):
self.assertEqual(True, srvc.bar_called)

def testServiceStub(self):

class MockRpcChannel:
class MockRpcChannel(service.RpcChannel):
def CallMethod(self, method, controller, request,
response_class, callback):
self.method = method
Expand Down
8 changes: 4 additions & 4 deletions python/google/protobuf/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing the following fatal error in protobuf==5.29.0:

IndentationError: unindent does not match any outer indentation level (service.py, line 78)


def GetRequestClass(self, method_descriptor):
"""Returns the class of the request message for the specified method.
Expand Down
Loading