locust 2.29.2.dev32__py3-none-any.whl → 2.29.2.dev42__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.
Files changed (42) hide show
  1. locust/_version.py +6 -2
  2. locust/contrib/fasthttp.py +1 -1
  3. locust/dispatch.py +7 -6
  4. locust/stats.py +4 -17
  5. {locust-2.29.2.dev32.dist-info → locust-2.29.2.dev42.dist-info}/METADATA +31 -26
  6. locust-2.29.2.dev42.dist-info/RECORD +49 -0
  7. locust-2.29.2.dev42.dist-info/WHEEL +4 -0
  8. locust-2.29.2.dev42.dist-info/entry_points.txt +3 -0
  9. locust/test/__init__.py +0 -15
  10. locust/test/fake_module1_for_env_test.py +0 -7
  11. locust/test/fake_module2_for_env_test.py +0 -7
  12. locust/test/mock_locustfile.py +0 -56
  13. locust/test/mock_logging.py +0 -28
  14. locust/test/test_debugging.py +0 -39
  15. locust/test/test_dispatch.py +0 -4170
  16. locust/test/test_env.py +0 -283
  17. locust/test/test_fasthttp.py +0 -785
  18. locust/test/test_http.py +0 -325
  19. locust/test/test_interruptable_task.py +0 -48
  20. locust/test/test_load_locustfile.py +0 -228
  21. locust/test/test_locust_class.py +0 -831
  22. locust/test/test_log.py +0 -237
  23. locust/test/test_main.py +0 -2264
  24. locust/test/test_old_wait_api.py +0 -0
  25. locust/test/test_parser.py +0 -450
  26. locust/test/test_runners.py +0 -4476
  27. locust/test/test_sequential_taskset.py +0 -157
  28. locust/test/test_stats.py +0 -866
  29. locust/test/test_tags.py +0 -440
  30. locust/test/test_taskratio.py +0 -94
  31. locust/test/test_users.py +0 -69
  32. locust/test/test_util.py +0 -33
  33. locust/test/test_wait_time.py +0 -79
  34. locust/test/test_web.py +0 -1257
  35. locust/test/test_zmqrpc.py +0 -58
  36. locust/test/testcases.py +0 -248
  37. locust/test/util.py +0 -88
  38. locust-2.29.2.dev32.dist-info/RECORD +0 -79
  39. locust-2.29.2.dev32.dist-info/WHEEL +0 -5
  40. locust-2.29.2.dev32.dist-info/entry_points.txt +0 -2
  41. locust-2.29.2.dev32.dist-info/top_level.txt +0 -1
  42. {locust-2.29.2.dev32.dist-info → locust-2.29.2.dev42.dist-info}/LICENSE +0 -0
locust/_version.py CHANGED
@@ -3,6 +3,7 @@
3
3
  TYPE_CHECKING = False
4
4
  if TYPE_CHECKING:
5
5
  from typing import Tuple, Union
6
+
6
7
  VERSION_TUPLE = Tuple[Union[int, str], ...]
7
8
  else:
8
9
  VERSION_TUPLE = object
@@ -12,5 +13,8 @@ __version__: str
12
13
  __version_tuple__: VERSION_TUPLE
13
14
  version_tuple: VERSION_TUPLE
14
15
 
15
- __version__ = version = '2.29.2.dev32'
16
- __version_tuple__ = version_tuple = (2, 29, 2, 'dev32')
16
+
17
+ __version__ = "2.29.2.dev42"
18
+ version = __version__
19
+ __version_tuple__ = (2, 29, 2, "dev42")
20
+ version_tuple = __version_tuple__
@@ -483,7 +483,7 @@ class FastResponse(CompatResponse):
483
483
 
484
484
  _response: HTTPSocketPoolResponse | None = None
485
485
 
486
- encoding: str | None = None
486
+ encoding: str | float | None = None
487
487
  """In some cases setting the encoding explicitly is needed. If so, do it before calling .text"""
488
488
 
489
489
  request: FastRequest | None = None
locust/dispatch.py CHANGED
@@ -90,13 +90,13 @@ class UsersDispatcher(Iterator):
90
90
  assert len(user_classes) > 0
91
91
  assert len(set(self._user_classes)) == len(self._user_classes)
92
92
 
93
- self._target_user_count: int = None
93
+ self._target_user_count: int = 0
94
94
 
95
- self._spawn_rate: float = None
95
+ self._spawn_rate: float = 0.0
96
96
 
97
- self._user_count_per_dispatch_iteration: int = None
97
+ self._user_count_per_dispatch_iteration: int = 0
98
98
 
99
- self._wait_between_dispatch: float = None
99
+ self._wait_between_dispatch: float = 0.0
100
100
 
101
101
  self._initial_users_on_workers = {
102
102
  worker_node.id: {user_class.__name__: 0 for user_class in self._user_classes}
@@ -107,7 +107,8 @@ class UsersDispatcher(Iterator):
107
107
 
108
108
  self._current_user_count = self.get_current_user_count()
109
109
 
110
- self._dispatcher_generator: Generator[dict[str, dict[str, int]], None, None] = None
110
+ self._dispatcher_generator: Generator[dict[str, dict[str, int]], None, None] = None # type: ignore
111
+ # a generator is assigned (in new_dispatch()) to _dispatcher_generator before it's used
111
112
 
112
113
  self._user_generator = self._user_gen()
113
114
 
@@ -131,7 +132,7 @@ class UsersDispatcher(Iterator):
131
132
  return sum(map(sum, map(dict.values, self._users_on_workers.values())))
132
133
 
133
134
  @property
134
- def dispatch_in_progress(self):
135
+ def dispatch_in_progress(self) -> bool:
135
136
  return self._dispatch_in_progress
136
137
 
137
138
  @property
locust/stats.py CHANGED
@@ -9,25 +9,12 @@ import signal
9
9
  import time
10
10
  from abc import abstractmethod
11
11
  from collections import OrderedDict, defaultdict, namedtuple
12
- from collections import (
13
- OrderedDict as OrderedDictType,
14
- )
15
12
  from collections.abc import Iterable
16
13
  from copy import copy
17
14
  from html import escape
18
15
  from itertools import chain
19
- from tempfile import NamedTemporaryFile
20
16
  from types import FrameType
21
- from typing import (
22
- TYPE_CHECKING,
23
- Any,
24
- Callable,
25
- NoReturn,
26
- Protocol,
27
- TypedDict,
28
- TypeVar,
29
- cast,
30
- )
17
+ from typing import TYPE_CHECKING, Any, Callable, NoReturn, Protocol, TypedDict, TypeVar, cast
31
18
 
32
19
  import gevent
33
20
 
@@ -319,12 +306,12 @@ class StatsEntry:
319
306
  A {response_time => count} dict that holds the response time distribution of all
320
307
  the requests.
321
308
 
322
- The keys (the response time in ms) are rounded to store 1, 2, ... 9, 10, 20. .. 90,
323
- 100, 200 .. 900, 1000, 2000 ... 9000, in order to save memory.
309
+ The keys (the response time in ms) are rounded to store 1, 2, ... 98, 99, 100, 110, 120, ... 980, 990, 1000,
310
+ 1100, 1200, ... 9800, 9900, 10_000, 11_000, 12_000 ... in order to save memory.
324
311
 
325
312
  This dict is used to calculate the median and percentile response times.
326
313
  """
327
- self.response_times_cache: OrderedDictType[int, CachedResponseTimes] | None = None
314
+ self.response_times_cache: OrderedDict[int, CachedResponseTimes] | None = None
328
315
  """
329
316
  If use_response_times_cache is set to True, this will be a {timestamp => CachedResponseTimes()}
330
317
  OrderedDict that holds a copy of the response_times dict for each of the last 20 seconds.
@@ -1,15 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: locust
3
- Version: 2.29.2.dev32
3
+ Version: 2.29.2.dev42
4
4
  Summary: Developer-friendly load testing framework
5
+ Home-page: https://locust.io/
5
6
  License: MIT
6
- Project-URL: Homepage, https://github.com/locustio/locust
7
- Project-URL: Documentation, https://docs.locust.io/
8
- Project-URL: Code, https://github.com/locustio/locust
9
- Project-URL: Help/Questions, https://stackoverflow.com/questions/tagged/locust
10
- Project-URL: Issue tracker, https://github.com/locustio/locust/issues
11
- Classifier: Topic :: Software Development :: Testing :: Traffic Generation
7
+ Author: Jonatan Heyman
8
+ Maintainer: Lars Holmberg
9
+ Requires-Python: >=3.9
12
10
  Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: System Administrators
13
13
  Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Programming Language :: Python
@@ -18,29 +18,32 @@ Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Intended Audience :: Developers
22
- Classifier: Intended Audience :: System Administrators
23
21
  Classifier: Topic :: Software Development :: Testing
24
22
  Classifier: Topic :: Software Development :: Testing :: Traffic Generation
25
23
  Classifier: Topic :: System :: Distributed Computing
26
- Requires-Python: >=3.9
24
+ Requires-Dist: ConfigArgParse (>=1.5.5)
25
+ Requires-Dist: Flask-Cors (>=3.0.10)
26
+ Requires-Dist: Flask-Login (>=0.6.3)
27
+ Requires-Dist: Werkzeug (>=2.0.0)
28
+ Requires-Dist: flask (>=2.0.0)
29
+ Requires-Dist: gevent (>=22.10.2)
30
+ Requires-Dist: geventhttpclient (>=2.3.1)
31
+ Requires-Dist: msgpack (>=1.0.0)
32
+ Requires-Dist: psutil (>=5.9.1)
33
+ Requires-Dist: pywin32 ; sys_platform == "win32"
34
+ Requires-Dist: pyzmq (>=25.0.0)
35
+ Requires-Dist: requests (>=2.26.0) ; python_full_version <= "3.11.0"
36
+ Requires-Dist: requests (>=2.32.2) ; python_full_version > "3.11.0"
37
+ Requires-Dist: tomli (>=1.1.0) ; python_version < "3.11"
38
+ Requires-Dist: typing_extensions (>=4.6.0) ; python_version < "3.11"
39
+ Project-URL: Documentation, https://docs.locust.io/
40
+ Project-URL: Help/Questions, https://github.com/orgs/locustio/discussions/
41
+ Project-URL: Issue Tracker, https://github.com/locustio/locust/issues
42
+ Project-URL: Repository, https://github.com/locustio/locust
43
+ Project-URL: Stack Overflow, https://stackoverflow.com/questions/tagged/locust
44
+ Project-URL: Slack, https://locustio.slack.com/
45
+ Project-URL: Slack/Signup, https://communityinviter.com/apps/locustio/locust
27
46
  Description-Content-Type: text/markdown
28
- License-File: LICENSE
29
- Requires-Dist: gevent >=22.10.2
30
- Requires-Dist: flask >=2.0.0
31
- Requires-Dist: Werkzeug >=2.0.0
32
- Requires-Dist: requests >=2.26.0
33
- Requires-Dist: msgpack >=1.0.0
34
- Requires-Dist: pyzmq >=25.0.0
35
- Requires-Dist: geventhttpclient >=2.3.1
36
- Requires-Dist: ConfigArgParse >=1.5.5
37
- Requires-Dist: psutil >=5.9.1
38
- Requires-Dist: Flask-Login >=0.6.3
39
- Requires-Dist: Flask-Cors >=3.0.10
40
- Requires-Dist: pywin32 ; platform_system == "Windows"
41
- Requires-Dist: tomli >=1.1.0 ; python_version < "3.11"
42
- Requires-Dist: typing-extensions >=4.6.0 ; python_version < "3.11"
43
- Requires-Dist: requests >=2.32.2 ; python_version > "3.11"
44
47
 
45
48
  # Locust
46
49
 
@@ -112,6 +115,7 @@ Locust's code base is intentionally kept small and doesn't solve everything out
112
115
 
113
116
  * Documentation: [docs.locust.io](https://docs.locust.io)
114
117
  * Support/Questions: [StackOverflow](https://stackoverflow.com/questions/tagged/locust)
118
+ * Github Discussions: [Github Discussions](https://github.com/orgs/locustio/discussions)
115
119
  * Chat/discussion: [Slack](https://locustio.slack.com) [(signup)](https://communityinviter.com/apps/locustio/locust)
116
120
 
117
121
  ## Authors
@@ -124,3 +128,4 @@ Locust's code base is intentionally kept small and doesn't solve everything out
124
128
  ## License
125
129
 
126
130
  Open source licensed under the MIT license (see _LICENSE_ file for details).
131
+
@@ -0,0 +1,49 @@
1
+ locust/__init__.py,sha256=Hmw2vNf75eLQ1mQIPXAwlQrJ_XFY65MOb92fGsNCukQ,1458
2
+ locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
3
+ locust/_version.py,sha256=lz-VFOL8BSOzklrR9XsmlGd2RsoIxkCjTCovy1iiKAM,460
4
+ locust/argument_parser.py,sha256=sjQoJ1NTac9LdNYT7zn8RajlWqBQs8YFNv6uRExb2gg,28941
5
+ locust/clients.py,sha256=OHPv6hBAt4gt3HI67yqyT1qrSsF8uMdCwIRu0kIsRWI,19491
6
+ locust/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ locust/contrib/fasthttp.py,sha256=1hR2WK-3ACGVsU6Fu4Z4KucVzL1LXMLG6k54KeZdt78,28509
8
+ locust/debug.py,sha256=We6Z9W0btkKSc7PxWmrZx-xMynvOOsKhG6jmDgQin0g,5134
9
+ locust/dispatch.py,sha256=0rGny9P8dEq2Kg7exRWPorKQ5D1LnhHd2xG5Jq7ge7g,17107
10
+ locust/env.py,sha256=sP-fCnZs0e2xodRemLHgTgyyUt5eezwtdA9WsCoqJkQ,12767
11
+ locust/event.py,sha256=iXEwIYFzra-j1WRldXB9SUibydtD8q8EIKaFPGTTIjk,8729
12
+ locust/exception.py,sha256=jGgJ32ubuf4pWdlaVOkbh2Y0LlG0_DHi-lv3ib8ppOE,1791
13
+ locust/html.py,sha256=_n3aB3fxiYzSeE_7RqHF3iiEPjPnbQ3e2Pw9P8AVtPU,3920
14
+ locust/input_events.py,sha256=ZIyePyAMuA_YFYWg18g_pE4kwuQV3RbEB250MzXRwjY,3314
15
+ locust/log.py,sha256=Wrkn0Ibugh5Sqjm4hGQ2-jUsy1tNMBdTctp4FyXQI24,3457
16
+ locust/main.py,sha256=NGjL5QqakU5aeyUzwu2Fh00xVZfC3eoBE3DtfOmRtcM,27854
17
+ locust/py.typed,sha256=gkWLl8yD4mIZnNYYAIRM8g9VarLvWmTAFeUfEbxJLBw,65
18
+ locust/rpc/__init__.py,sha256=nVGoHWFQxZjnhCDWjbgXIbmFbN9sizAjkhvSs9_642c,58
19
+ locust/rpc/protocol.py,sha256=n-rb3GZQcAlldYDj4E4GuFGylYj_26GSS5U29meft5Y,1282
20
+ locust/rpc/zmqrpc.py,sha256=AAY6w7wSFHsW34qqN28666boHFf6dTSAXPQJnAO6iUI,2707
21
+ locust/runners.py,sha256=otH-ZxTygBRXN46Nmocs5ac8R4b0MsnKAUcHRwVnD1E,69869
22
+ locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
23
+ locust/stats.py,sha256=KLVIdw-jh09u75JFucl7PHXNktAnPnQx-DrV_rUH5xM,45772
24
+ locust/user/__init__.py,sha256=S2yvmI_AU9kXirtTIVqiV_Hs7yXzqXvaSgkNo9ig-fk,71
25
+ locust/user/inspectuser.py,sha256=KgrWHyE5jhK6or58R7soLRf-_st42AaQrR72qbiXw9E,2641
26
+ locust/user/sequential_taskset.py,sha256=SbrrGU9HV2nEWe6zQVtjymn8NgPISP7QSNoVdyoXjYg,2687
27
+ locust/user/task.py,sha256=doCOclhPC92ePfVa1KfIceZC-YofpnM4VaKplWYNH8o,16730
28
+ locust/user/users.py,sha256=BsKyxzLq1lmdYBXnwHNyMH_Nxfy7QRlyLnfiE8539HY,9989
29
+ locust/user/wait_time.py,sha256=bGRKMVx4lom75sX3POYJUa1CPeME2bEAXG6CEgxSO5U,2675
30
+ locust/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ locust/util/cache.py,sha256=IxbpGawl0-hoWKvCrtksxjSLf2GbBBTVns06F7mFBkM,1062
32
+ locust/util/date.py,sha256=pqyUuqzPds-A8ai6ZYTxe5Eak1M1BR9iuQcqEcrtHwc,179
33
+ locust/util/deprecation.py,sha256=pFipULkYFjYnuFSycJZ0s95r0CTSlvx8otGnqSu1bsQ,2028
34
+ locust/util/exception_handler.py,sha256=jTMyBq2a0O07fRjmqGkheyaPj58tUgnbbcjoesKGPws,797
35
+ locust/util/load_locustfile.py,sha256=hn70KcIG8jHmZyuKv2pcEmwgWtOEu24Efeji1KRYNUE,2964
36
+ locust/util/rounding.py,sha256=5haxR8mKhATqag6WvPby-MSRRgIw5Ob6thbyvMYZM7o,92
37
+ locust/util/timespan.py,sha256=Y0LtnhUq2Mq19p04u0XtBlYQ_-S2cRvwRdgru8W9WhA,986
38
+ locust/web.py,sha256=rN1NVeZ9LKSEeDwvpRbOJ0bcy8U1U4VjP-7vK7ejlwM,27367
39
+ locust/webui/dist/assets/favicon.ico,sha256=IUl-rYqfpHdV38e-s0bkmFIeLS-n3Ug0DQxk-h202hI,8348
40
+ locust/webui/dist/assets/index-e9ad42b4.js,sha256=aXKF6Qug5b9n5e160A0PFvM0qgJQgVwtwQhLwCsek-4,1647570
41
+ locust/webui/dist/assets/logo.png,sha256=EIVPqr6wE_yqguHaqFHIsH0ZACLSrvNWyYO7PbyIj4w,19299
42
+ locust/webui/dist/auth.html,sha256=NE_pYWbFjnBEkq2tG5mS_9YoL7JHX4Gkx9zhQoxlSC8,501
43
+ locust/webui/dist/index.html,sha256=S78UvAUZbQ-sH0wBxqFKrT2ZSfRxUFGx5xwQY6FaVMk,507
44
+ locust/webui/dist/report.html,sha256=sOdZZVgZbqgu86BBCSQf3uQUYXgmgSnXF32JpnyAII8,513
45
+ locust-2.29.2.dev42.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
46
+ locust-2.29.2.dev42.dist-info/METADATA,sha256=zxWkyHFAuy0txwl12tVAxmjgvpmXHSgWdVeCOUk7nDk,7674
47
+ locust-2.29.2.dev42.dist-info/WHEEL,sha256=HBsDV7Hj4OTiS1GX6ua7iQXUQTB9UHftbBxr7Q8Xm9c,110
48
+ locust-2.29.2.dev42.dist-info/entry_points.txt,sha256=RhIxlLwU_Ae_WjimS5COUDLagdCh6IOMyLtgaQxNmlM,43
49
+ locust-2.29.2.dev42.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.9.0
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-manylinux_2_35_x86_64
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ locust=locust.main:main
3
+
locust/test/__init__.py DELETED
@@ -1,15 +0,0 @@
1
- try:
2
- import resource
3
-
4
- # work around occasional "zmq.error.ZMQError: Too many open files"
5
- # this is done in main.py when running locust proper so we need to do it here as well
6
- resource.setrlimit(
7
- resource.RLIMIT_NOFILE,
8
- (
9
- 10000,
10
- resource.RLIM_INFINITY,
11
- ),
12
- )
13
- changed_rlimit = True
14
- except Exception:
15
- changed_rlimit = False
@@ -1,7 +0,0 @@
1
- """Module for locust.test.test_env.TestEnvironment.test_user_classes_with_same_name_is_error"""
2
-
3
- from locust import User
4
-
5
-
6
- class MyUserWithSameName(User):
7
- pass
@@ -1,7 +0,0 @@
1
- """Module for locust.test.test_env.TestEnvironment.test_user_classes_with_same_name_is_error"""
2
-
3
- from locust import User
4
-
5
-
6
- class MyUserWithSameName(User):
7
- pass
@@ -1,56 +0,0 @@
1
- import os
2
- import random
3
- import time
4
- from contextlib import contextmanager
5
-
6
- MOCK_LOCUSTFILE_CONTENT = '''
7
- """This is a mock locust file for unit testing"""
8
-
9
- from locust import HttpUser, TaskSet, task, between, LoadTestShape
10
-
11
-
12
- def index(l):
13
- l.client.get("/")
14
-
15
- def stats(l):
16
- l.client.get("/stats/requests")
17
-
18
-
19
- class UserTasks(TaskSet):
20
- # one can specify tasks like this
21
- tasks = [index, stats]
22
-
23
-
24
- class UserSubclass(HttpUser):
25
- host = "http://127.0.0.1:8089"
26
- wait_time = between(2, 5)
27
- tasks = [UserTasks]
28
-
29
-
30
- class NotUserSubclass():
31
- host = "http://localhost:8000"
32
-
33
- '''
34
-
35
-
36
- class MockedLocustfile:
37
- __slots__ = ["filename", "directory", "file_path"]
38
-
39
-
40
- @contextmanager
41
- def mock_locustfile(filename_prefix="mock_locustfile", content=MOCK_LOCUSTFILE_CONTENT, dir=None):
42
- mocked = MockedLocustfile()
43
- mocked.directory = dir or os.path.dirname(os.path.abspath(__file__))
44
- mocked.filename = "%s_%s_%i.py" % (
45
- filename_prefix,
46
- str(time.time()).replace(".", "_"),
47
- random.randint(0, 100000),
48
- )
49
- mocked.file_path = os.path.join(mocked.directory, mocked.filename)
50
- with open(mocked.file_path, "w") as file:
51
- file.write(content)
52
-
53
- try:
54
- yield mocked
55
- finally:
56
- os.remove(mocked.file_path)
@@ -1,28 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import logging
4
- from types import TracebackType
5
- from typing import Union
6
-
7
- LogMessage = list[Union[str, dict[str, TracebackType]]]
8
-
9
-
10
- class MockedLoggingHandler(logging.Handler):
11
- debug: list[LogMessage] = []
12
- warning: list[LogMessage] = []
13
- info: list[LogMessage] = []
14
- error: list[LogMessage] = []
15
- critical: list[LogMessage] = []
16
-
17
- def emit(self, record):
18
- if record.exc_info:
19
- value = {"message": record.getMessage(), "exc_info": record.exc_info}
20
- else:
21
- value = record.getMessage()
22
- getattr(self.__class__, record.levelname.lower()).append(value)
23
-
24
- @classmethod
25
- def reset(cls):
26
- for attr in dir(cls):
27
- if isinstance(getattr(cls, attr), list):
28
- setattr(cls, attr, [])
@@ -1,39 +0,0 @@
1
- from locust import debug, task
2
- from locust.test.testcases import LocustTestCase
3
- from locust.user.task import LOCUST_STATE_STOPPING
4
- from locust.user.users import HttpUser
5
-
6
- import os
7
- from threading import Timer
8
- from unittest import mock
9
-
10
-
11
- class DebugTestCase(LocustTestCase):
12
- def setUp(self):
13
- super().setUp()
14
- debug._env = None
15
-
16
-
17
- class TestDebugging(DebugTestCase):
18
- @mock.patch.dict(os.environ, {"LOCUST_HOST": "http://localhost"})
19
- def test_run_single_user_pass_host_to_user_classes(self):
20
- """
21
- HttpUser should receive host from environment variable
22
- """
23
-
24
- class MyUser1(HttpUser):
25
- @task
26
- def my_task(self):
27
- pass
28
-
29
- def _stop_user():
30
- if user := getattr(debug._env, "single_user_instance", None):
31
- user._state = LOCUST_STATE_STOPPING
32
-
33
- t = Timer(1, _stop_user)
34
- t.start()
35
-
36
- debug.run_single_user(
37
- MyUser1,
38
- loglevel=None, # another log setup might mess with other tests...
39
- )