Calling gRPC method in pytest

324 views
Skip to first unread message

Jason Hoppes

unread,
May 31, 2022, 11:04:16 AM5/31/22
to grpc.io
I have a method AddUser in my gRPC interface. I am trying to test using pytest. I created a mock Context.

The generated code creates the signature:

def AddUser(self, request, context)

When I call this with the MockContext object I get the error:

TypeError: unsupported operand type(s) for +: 'float' and 'MockContext'

For s & g I added the __add__ method to my context object and returned a float. I still got the same error.

Could someone please help me so,ve this problem?

Thank you.

Jason Hoppes

unread,
May 31, 2022, 12:37:17 PM5/31/22
to grpc.io
BTW the MockObject inherits users_grpc.grpc.ServicerContext.

Lidi Zheng

unread,
Jun 2, 2022, 3:59:31 PM6/2/22
to grpc.io
Can you provide a reproduce case and post the bug on GitHub grpc/grpc repo?
Reply all
Reply to author
Forward
0 new messages