Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Janczara committed Sep 22, 2023
1 parent e297697 commit 40d6106
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion locust/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def request(self, method, url, name=None, catch_response=False, context={}, **kw

# use stream=True to avoid closing socket and downloading content at the beginning
# we'll download content if actually requested a bit later
#
#
# a bit of a hack to actually estimate fetching time
stream = kwargs.pop("stream", False)

Expand Down
10 changes: 8 additions & 2 deletions locust/test/test_fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ def test_response_times_are_separated_in_request_metadata(self):
in request metadata
"""
kwargs = {}

def on_request(**kw):
kwargs.update(kw)

self.environment.events.request.add_listener(on_request)
s = self.get_client()

Expand All @@ -88,7 +90,9 @@ def on_request(**kw):
self.assertLess(kwargs["response_fetching_time"], 10)
self.assertAlmostEqual(
self.runner.stats.get("/streaming/50", method="GET").avg_response_time,
kwargs["response_waiting_time"] + kwargs["response_fetching_time"], delta=0.1)
kwargs["response_waiting_time"] + kwargs["response_fetching_time"],
delta=0.1,
)
self.runner.stats.clear_all()
kwargs.clear()

Expand All @@ -99,7 +103,9 @@ def on_request(**kw):
self.assertGreater(kwargs["response_fetching_time"], 250)
self.assertAlmostEqual(
self.runner.stats.get("/streaming/50", method="GET").avg_response_time,
kwargs["response_waiting_time"] + kwargs["response_fetching_time"], delta=0.1)
kwargs["response_waiting_time"] + kwargs["response_fetching_time"],
delta=0.1,
)

def test_slow_redirect(self):
s = self.get_client()
Expand Down
11 changes: 8 additions & 3 deletions locust/test/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ def test_response_times_are_separated_in_request_metadata(self):
in request metadata
"""
kwargs = {}

def on_request(**kw):
kwargs.update(kw)

self.environment.events.request.add_listener(on_request)
s = self.get_client()

Expand All @@ -79,7 +81,9 @@ def on_request(**kw):
self.assertLess(kwargs["response_fetching_time"], 10)
self.assertAlmostEqual(
self.runner.stats.get("/streaming/50", method="GET").avg_response_time,
kwargs["response_waiting_time"] + kwargs["response_fetching_time"], delta=0.1)
kwargs["response_waiting_time"] + kwargs["response_fetching_time"],
delta=0.1,
)
self.runner.stats.clear_all()
kwargs.clear()

Expand All @@ -90,8 +94,9 @@ def on_request(**kw):
self.assertGreater(kwargs["response_fetching_time"], 250)
self.assertAlmostEqual(
self.runner.stats.get("/streaming/50", method="GET").avg_response_time,
kwargs["response_waiting_time"] + kwargs["response_fetching_time"], delta=0.1)

kwargs["response_waiting_time"] + kwargs["response_fetching_time"],
delta=0.1,
)

def test_slow_redirect(self):
s = self.get_client()
Expand Down

0 comments on commit 40d6106

Please sign in to comment.