locust 2.39.1.dev14__py3-none-any.whl → 2.39.2.dev5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
locust/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '2.39.1.dev14'
32
- __version_tuple__ = version_tuple = (2, 39, 1, 'dev14')
31
+ __version__ = version = '2.39.2.dev5'
32
+ __version_tuple__ = version_tuple = (2, 39, 2, 'dev5')
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- from locust.env import Environment
4
3
  from locust.exception import CatchResponseError, LocustError, ResponseError
5
4
  from locust.user import User
6
5
  from locust.util.deprecation import DeprecatedFastHttpLocustClass as FastHttpLocust # noqa: F401
@@ -106,16 +105,16 @@ class FastHttpSession:
106
105
 
107
106
  def __init__(
108
107
  self,
109
- environment: Environment,
110
- base_url: str,
108
+ base_url: str | None,
109
+ request_event,
111
110
  user: User | None,
112
111
  insecure=True,
113
112
  client_pool: HTTPClientPool | None = None,
114
113
  ssl_context_factory: Callable | None = None,
115
114
  **kwargs,
116
115
  ) -> None:
117
- self.environment = environment
118
116
  self.base_url = base_url
117
+ self.request_event = request_event
119
118
  self.cookiejar = CookieJar()
120
119
  self.user = user
121
120
  if not ssl_context_factory:
@@ -132,18 +131,28 @@ class FastHttpSession:
132
131
  )
133
132
 
134
133
  # Check for basic authentication
135
- parsed_url = urlparse(self.base_url)
136
- if parsed_url.username and parsed_url.password:
137
- netloc = parsed_url.hostname or ""
138
- if parsed_url.port:
139
- netloc += ":%d" % parsed_url.port
140
-
141
- # remove username and password from the base_url
142
- self.base_url = urlunparse(
143
- (parsed_url.scheme, netloc, parsed_url.path, parsed_url.params, parsed_url.query, parsed_url.fragment)
144
- )
145
- # store authentication header (we construct this by using _basic_auth_str() function from requests.auth)
146
- self.auth_header = _construct_basic_auth_str(parsed_url.username, parsed_url.password)
134
+ if self.base_url:
135
+ parsed_url = urlparse(self.base_url)
136
+ if parsed_url.username and parsed_url.password:
137
+ netloc = parsed_url.hostname or ""
138
+ if parsed_url.port:
139
+ netloc += ":%d" % parsed_url.port
140
+
141
+ # remove username and password from the base_url
142
+ self.base_url = str(
143
+ urlunparse(
144
+ (
145
+ parsed_url.scheme,
146
+ netloc,
147
+ parsed_url.path,
148
+ parsed_url.params,
149
+ parsed_url.query,
150
+ parsed_url.fragment,
151
+ )
152
+ )
153
+ )
154
+ # store authentication header (we construct this by using _basic_auth_str() function from requests.auth)
155
+ self.auth_header = _construct_basic_auth_str(parsed_url.username, parsed_url.password)
147
156
 
148
157
  def _build_url(self, path: str) -> str:
149
158
  """prepend url with hostname unless it's already an absolute URL"""
@@ -273,7 +282,7 @@ class FastHttpSession:
273
282
  except HTTPParseError as e:
274
283
  request_meta["response_time"] = (time.perf_counter() - start_perf_counter) * 1000
275
284
  request_meta["exception"] = e
276
- self.environment.events.request.fire(**request_meta)
285
+ self.request_event.fire(**request_meta)
277
286
  return response
278
287
 
279
288
  # Record the consumed time
@@ -282,14 +291,14 @@ class FastHttpSession:
282
291
  request_meta["response_time"] = (time.perf_counter() - start_perf_counter) * 1000
283
292
 
284
293
  if catch_response:
285
- return ResponseContextManager(response, environment=self.environment, request_meta=request_meta)
294
+ return ResponseContextManager(response, request_event=self.request_event, request_meta=request_meta)
286
295
  else:
287
296
  try:
288
297
  response.raise_for_status()
289
298
  except FAILURE_EXCEPTIONS as e:
290
299
  request_meta["exception"] = e
291
300
 
292
- self.environment.events.request.fire(**request_meta)
301
+ self.request_event.fire(**request_meta)
293
302
  return response
294
303
 
295
304
  def delete(self, url: str, **kwargs: Unpack[RESTKwargs]) -> ResponseContextManager | FastResponse:
@@ -406,8 +415,8 @@ class FastHttpUser(User):
406
415
  )
407
416
 
408
417
  self.client: FastHttpSession = FastHttpSession(
409
- self.environment,
410
418
  base_url=self.host,
419
+ request_event=self.environment.events.request,
411
420
  network_timeout=self.network_timeout,
412
421
  connection_timeout=self.connection_timeout,
413
422
  max_redirects=self.max_redirects,
@@ -653,15 +662,14 @@ class ResponseContextManager(FastResponse):
653
662
  _manual_result = None
654
663
  _entered = False
655
664
 
656
- def __init__(self, response, environment, request_meta):
665
+ def __init__(self, response, request_event, request_meta):
657
666
  # copy data from response to this object
658
667
  self.__dict__ = response.__dict__
659
668
  try:
660
669
  self._cached_content = response._cached_content
661
670
  except AttributeError:
662
671
  pass
663
- # store reference to locust Environment
664
- self._environment = environment
672
+ self._request_event = request_event
665
673
  self.request_meta = request_meta
666
674
 
667
675
  def __enter__(self):
@@ -696,7 +704,7 @@ class ResponseContextManager(FastResponse):
696
704
  return True
697
705
 
698
706
  def _report_request(self):
699
- self._environment.events.request.fire(**self.request_meta)
707
+ self._request_event.fire(**self.request_meta)
700
708
 
701
709
  def success(self):
702
710
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: locust
3
- Version: 2.39.1.dev14
3
+ Version: 2.39.2.dev5
4
4
  Summary: Developer-friendly load testing framework
5
5
  Project-URL: homepage, https://locust.io/
6
6
  Project-URL: repository, https://github.com/locustio/locust
@@ -1,6 +1,6 @@
1
1
  locust/__init__.py,sha256=HadpgGidiyCDPSKwkxrk1Qw6eB7dTmftNJVftuJzAiw,1876
2
2
  locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
3
- locust/_version.py,sha256=Tsy6z8wYQLE6XjotjFe5SBv-bA3UUIVcUI7XKaexYno,721
3
+ locust/_version.py,sha256=fRtcXazmY5njv-S1j8yP2Xoo7Da8whdN6bT5b5ZLlvY,719
4
4
  locust/argument_parser.py,sha256=t6mAoK9u13DxC9UH-alVqS6fFABFTyNWSJG89yQ4QQQ,33056
5
5
  locust/clients.py,sha256=o-277lWQdpmPnoRTdf3IQVNPQT8LMFDtPtuxbLHQIIs,19286
6
6
  locust/debug.py,sha256=7CCm8bIg44uGH2wqBlo1rXBzV2VzwPicLxLewz8r5CQ,5099
@@ -18,7 +18,7 @@ locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
18
18
  locust/stats.py,sha256=qyoSKT0i7RunLDj5pMGqizK1Sp8bcqUsXwh2m4_DpR8,47203
19
19
  locust/web.py,sha256=HLFN9jUtKG3sMIKu_Xw9wtvTAFxXvzDHdtLtfb_JxUQ,31849
20
20
  locust/contrib/__init__.py,sha256=LtZN7MczpIAbZkN7PT2h8W2wgb9nBl6cDXbFCVsV4fo,290
21
- locust/contrib/fasthttp.py,sha256=QfVpcdo5oKOO1rKLXeCeTJ4t57XU1lhIIWeUeeSJtIE,29650
21
+ locust/contrib/fasthttp.py,sha256=c8MznjqbtYTKZPc20OC4GCiaENDCJmmNSNuHqtMhh2Q,29883
22
22
  locust/contrib/milvus.py,sha256=YabgLd0lImzWupJFCm0OZAW-Nxeibwn91ldWpZ2irDo,12811
23
23
  locust/contrib/mongodb.py,sha256=1seUYgJOaNKwybYOP9PUEVhgl8hGy-G33f8lFj3R8W8,1246
24
24
  locust/contrib/oai.py,sha256=Ot3T8lp31ThckGbNps86oVvq6Vn845Eec0mxhDmONDE,2684
@@ -55,8 +55,8 @@ locust/webui/dist/assets/index-BjqxSg7R.js,sha256=3JyrKWfAg8LlTy2bxAJh73c6njNPhN
55
55
  locust/webui/dist/assets/terminal.gif,sha256=iw80LO2u0dnf4wpGfFJZauBeKTcSpw9iUfISXT2nEF4,75302
56
56
  locust/webui/dist/assets/testruns-dark.png,sha256=G4p2VZSBuuqF4neqUaPSshIp5OKQJ_Bvb69Luj6XuVs,125231
57
57
  locust/webui/dist/assets/testruns-light.png,sha256=JinGDiiBPOkhpfF-XCbmQqhRInqItrjrBTLKt5MlqVI,130301
58
- locust-2.39.1.dev14.dist-info/METADATA,sha256=6GFxI4dYERIhDDzbeKD1d9tiIL5W-60TQPQ3gEb7yHs,9563
59
- locust-2.39.1.dev14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
- locust-2.39.1.dev14.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
61
- locust-2.39.1.dev14.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
62
- locust-2.39.1.dev14.dist-info/RECORD,,
58
+ locust-2.39.2.dev5.dist-info/METADATA,sha256=QPujpa-6pGk9u1kOGbIvJxfXBQXx5th08GUINKOASVM,9562
59
+ locust-2.39.2.dev5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
+ locust-2.39.2.dev5.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
61
+ locust-2.39.2.dev5.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
62
+ locust-2.39.2.dev5.dist-info/RECORD,,