diff --git a/stripe/_stripe_response.py b/stripe/_stripe_response.py index 57844285d..b50121546 100644 --- a/stripe/_stripe_response.py +++ b/stripe/_stripe_response.py @@ -60,3 +60,6 @@ def __init__( def stream(self) -> AsyncIterable[bytes]: return self._stream + + async def read(self) -> bytes: + return b"".join([chunk async for chunk in self._stream]) diff --git a/tests/test_integration.py b/tests/test_integration.py index 9b066304a..c6dfb4b7a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -446,14 +446,8 @@ def do_request(self, n): self.setup_mock_server(MockServerRequestHandler) stripe.upload_api_base = "http://localhost:%s" % self.mock_server_port - chunks = [] result = await stripe.Quote.pdf_async("qt_123") - async for chunk in result.stream(): - chunks.append(str(chunk, "utf-8")) - - MockServerRequestHandler.get_requests(1) - - assert "".join(chunks) == "hello" + assert str(await result.read(), "utf-8") == "hello" @pytest.mark.anyio async def test_async_httpx_stream_error(self):