Skip to content

Commit

Permalink
Merge pull request #1105 from skivis/fix/catch-response
Browse files Browse the repository at this point in the history
Fix empty response.content when using catch_response=True with FastHttpLocust
  • Loading branch information
heyman authored Oct 18, 2019
2 parents 644496f + dabc1b8 commit 2a0d18a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions locust/contrib/fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ class ResponseContextManager(FastResponse):
def __init__(self, response):
# copy data from response to this object
self.__dict__ = response.__dict__
self._cached_content = response.content

def __enter__(self):
return self
Expand Down
1 change: 1 addition & 0 deletions locust/test/test_fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def test_catch_response(self):
with self.locust.client.get("/ultra_fast", catch_response=True) as response: pass
self.assertEqual(1, self.num_failures)
self.assertEqual(1, self.num_success)
self.assertIn("ultra fast", str(response.content))

with self.locust.client.get("/ultra_fast", catch_response=True) as response:
raise ResponseError("Not working")
Expand Down

0 comments on commit 2a0d18a

Please sign in to comment.