0

so, I'm paching a method in pytest and I want to it to return rpc error with custom status code and message. I tried

my_error = grpc.RpcError()
my_error.code = ???
my_error.details = ???

so, there's no constructor for RpcError, so, I was wondering how do I set custom status code and message for mocking purposes. Is this doable?

so, in the code I'm testing, I have something like

except grpc.RpcError as e:
  print(e)

I want to see if the printed exception will be of certain format, and I'm only concerned with the status code and error details as of this moment.

Thanks

0 Answers0