Mocking gRPC status code ('RpcError' object has no attribute 'code') in Flask App
问题 I have to create a unittest that should mock a specific grpc status code (in my case I need NOT_FOUND status). This is what i want to mock: try: # my mocked function except grpc.RpcError as e: if e.code() == grpc.StatusCode.NOT_FOUND: # do something My unittest until now looks like this: def mock_function_which_raise_RpcError(): e = grpc.RpcError(grpc.StatusCode.NOT_FOUND) raise e class MyTestCase(BaseViewTestCase): @property def base_url(self): return '/myurl' @mock.patch('my_func', mock