Skip to content

Commit

Permalink
fix sync do_request().stream
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Dec 15, 2023
1 parent cf76592 commit 356ff41
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/integration/test_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ def __call__(self, *args, **kwargs):
return self.client.request(*args, timeout=60, **kwargs)

def stream(self, *args, **kwargs):
with self.client.stream(*args, **kwargs) as response:
return b"".join(response.iter_bytes())
if hasattr(self, "_client"):
with self.client.stream(*args, **kwargs) as response:
return b"".join(response.iter_bytes())

# Use one-time context and dispose of the client afterwards
with self:
with self.client.stream(*args, **kwargs) as response:
return b"".join(response.iter_bytes())


class DoAsyncRequest(BaseDoRequest):
Expand Down

0 comments on commit 356ff41

Please sign in to comment.