def patch_on_http_response(default_http_client: DefaultHTTPClient, abort_on=[]): def patched(self, resource, response): self.last_response = response return (response.status_code not in abort_on) default_http_client.on_http_response = types.MethodType( patched, default_http_client)
def patch_on_http_response(default_http_client: DefaultHTTPClient, abort_on=[]): def patched(self, method: str, url: str, response: Response, **kwargs): self.last_response = response return (response.status_code not in abort_on) default_http_client.on_http_response = types.MethodType( patched, default_http_client)