locust 2.29.2.dev34__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.
- locust/_version.py +6 -2
- locust/contrib/fasthttp.py +1 -1
- locust/dispatch.py +7 -6
- {locust-2.29.2.dev34.dist-info → locust-2.29.2.dev42.dist-info}/METADATA +31 -26
- {locust-2.29.2.dev34.dist-info → locust-2.29.2.dev42.dist-info}/RECORD +16 -46
- locust-2.29.2.dev42.dist-info/WHEEL +4 -0
- locust-2.29.2.dev42.dist-info/entry_points.txt +3 -0
- locust/test/__init__.py +0 -15
- locust/test/fake_module1_for_env_test.py +0 -7
- locust/test/fake_module2_for_env_test.py +0 -7
- locust/test/mock_locustfile.py +0 -56
- locust/test/mock_logging.py +0 -28
- locust/test/test_debugging.py +0 -39
- locust/test/test_dispatch.py +0 -4170
- locust/test/test_env.py +0 -283
- locust/test/test_fasthttp.py +0 -785
- locust/test/test_http.py +0 -325
- locust/test/test_interruptable_task.py +0 -48
- locust/test/test_load_locustfile.py +0 -228
- locust/test/test_locust_class.py +0 -831
- locust/test/test_log.py +0 -237
- locust/test/test_main.py +0 -2264
- locust/test/test_old_wait_api.py +0 -0
- locust/test/test_parser.py +0 -450
- locust/test/test_runners.py +0 -4476
- locust/test/test_sequential_taskset.py +0 -157
- locust/test/test_stats.py +0 -866
- locust/test/test_tags.py +0 -440
- locust/test/test_taskratio.py +0 -94
- locust/test/test_users.py +0 -69
- locust/test/test_util.py +0 -33
- locust/test/test_wait_time.py +0 -79
- locust/test/test_web.py +0 -1257
- locust/test/test_zmqrpc.py +0 -58
- locust/test/testcases.py +0 -248
- locust/test/util.py +0 -88
- locust-2.29.2.dev34.dist-info/WHEEL +0 -5
- locust-2.29.2.dev34.dist-info/entry_points.txt +0 -2
- locust-2.29.2.dev34.dist-info/top_level.txt +0 -1
- {locust-2.29.2.dev34.dist-info → locust-2.29.2.dev42.dist-info}/LICENSE +0 -0
locust/test/test_old_wait_api.py
DELETED
File without changes
|
locust/test/test_parser.py
DELETED
@@ -1,450 +0,0 @@
|
|
1
|
-
import locust
|
2
|
-
from locust.argument_parser import (
|
3
|
-
get_parser,
|
4
|
-
parse_locustfile_option,
|
5
|
-
parse_locustfile_paths,
|
6
|
-
parse_options,
|
7
|
-
ui_extra_args_dict,
|
8
|
-
)
|
9
|
-
|
10
|
-
import os
|
11
|
-
import unittest
|
12
|
-
from io import StringIO
|
13
|
-
from random import randint
|
14
|
-
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
15
|
-
from unittest import mock
|
16
|
-
|
17
|
-
from .mock_locustfile import mock_locustfile
|
18
|
-
from .testcases import LocustTestCase
|
19
|
-
|
20
|
-
|
21
|
-
class TestParser(unittest.TestCase):
|
22
|
-
def setUp(self):
|
23
|
-
self.parser = get_parser(default_config_files=[])
|
24
|
-
|
25
|
-
def test_default(self):
|
26
|
-
opts = self.parser.parse_args([])
|
27
|
-
self.assertEqual(opts.reset_stats, False)
|
28
|
-
self.assertEqual(opts.skip_log_setup, False)
|
29
|
-
|
30
|
-
def test_reset_stats(self):
|
31
|
-
args = ["--reset-stats"]
|
32
|
-
opts = self.parser.parse_args(args)
|
33
|
-
self.assertEqual(opts.reset_stats, True)
|
34
|
-
|
35
|
-
def test_skip_log_setup(self):
|
36
|
-
args = ["--skip-log-setup"]
|
37
|
-
opts = self.parser.parse_args(args)
|
38
|
-
self.assertEqual(opts.skip_log_setup, True)
|
39
|
-
|
40
|
-
def test_parse_options_from_conf_file(self):
|
41
|
-
with NamedTemporaryFile(mode="w", suffix=".conf") as file:
|
42
|
-
config_data = """\
|
43
|
-
locustfile = ./test_locustfile.py
|
44
|
-
web-host = 127.0.0.1
|
45
|
-
web-port = 45787
|
46
|
-
headless
|
47
|
-
tags = [Critical, Normal]
|
48
|
-
"""
|
49
|
-
|
50
|
-
file.write(config_data)
|
51
|
-
file.flush()
|
52
|
-
parser = get_parser(default_config_files=[file.name])
|
53
|
-
options = parser.parse_args(["-H", "https://example.com"])
|
54
|
-
|
55
|
-
self.assertEqual("./test_locustfile.py", options.locustfile)
|
56
|
-
self.assertEqual("127.0.0.1", options.web_host)
|
57
|
-
self.assertEqual(45787, options.web_port)
|
58
|
-
self.assertTrue(options.headless)
|
59
|
-
self.assertEqual(["Critical", "Normal"], options.tags)
|
60
|
-
self.assertEqual("https://example.com", options.host)
|
61
|
-
|
62
|
-
def test_parse_options_from_toml_file(self):
|
63
|
-
with NamedTemporaryFile(mode="w", suffix=".toml") as file:
|
64
|
-
config_data = """\
|
65
|
-
[tool.locust]
|
66
|
-
locustfile = "./test_locustfile.py"
|
67
|
-
web-host = "127.0.0.1"
|
68
|
-
web-port = 45787
|
69
|
-
headless = true
|
70
|
-
tags = ["Critical", "Normal"]
|
71
|
-
[tool.something_else]
|
72
|
-
this = "should be ignored by locust"
|
73
|
-
"""
|
74
|
-
|
75
|
-
file.write(config_data)
|
76
|
-
file.flush()
|
77
|
-
parser = get_parser(default_config_files=[file.name])
|
78
|
-
options = parser.parse_args(["-H", "https://example.com"])
|
79
|
-
|
80
|
-
self.assertEqual("./test_locustfile.py", options.locustfile)
|
81
|
-
self.assertEqual("127.0.0.1", options.web_host)
|
82
|
-
self.assertEqual(45787, options.web_port)
|
83
|
-
self.assertTrue(options.headless)
|
84
|
-
self.assertEqual(["Critical", "Normal"], options.tags)
|
85
|
-
self.assertEqual("https://example.com", options.host)
|
86
|
-
|
87
|
-
|
88
|
-
class TestArgumentParser(LocustTestCase):
|
89
|
-
def setUp(self):
|
90
|
-
super().setUp()
|
91
|
-
self.parent_dir = TemporaryDirectory()
|
92
|
-
self.child_dir = TemporaryDirectory(dir=self.parent_dir.name)
|
93
|
-
self.child_dir2 = TemporaryDirectory(dir=self.parent_dir.name)
|
94
|
-
|
95
|
-
def tearDown(self):
|
96
|
-
super().tearDown()
|
97
|
-
self.child_dir.cleanup()
|
98
|
-
self.parent_dir.cleanup()
|
99
|
-
|
100
|
-
def test_parse_options(self):
|
101
|
-
options = parse_options(
|
102
|
-
args=[
|
103
|
-
"-f",
|
104
|
-
"locustfile.py",
|
105
|
-
"-u",
|
106
|
-
"100",
|
107
|
-
"-r",
|
108
|
-
"10",
|
109
|
-
"-t",
|
110
|
-
"5m",
|
111
|
-
"--reset-stats",
|
112
|
-
"--stop-timeout",
|
113
|
-
"5",
|
114
|
-
"MyUserClass",
|
115
|
-
]
|
116
|
-
)
|
117
|
-
self.assertEqual("locustfile.py", options.locustfile)
|
118
|
-
self.assertEqual(100, options.num_users)
|
119
|
-
self.assertEqual(10, options.spawn_rate)
|
120
|
-
self.assertEqual("5m", options.run_time)
|
121
|
-
self.assertTrue(options.reset_stats)
|
122
|
-
self.assertEqual("5", options.stop_timeout)
|
123
|
-
self.assertEqual(["MyUserClass"], options.user_classes)
|
124
|
-
# check default arg
|
125
|
-
self.assertEqual(8089, options.web_port)
|
126
|
-
|
127
|
-
def test_parse_options_from_env(self):
|
128
|
-
os.environ["LOCUST_LOCUSTFILE"] = "locustfile.py"
|
129
|
-
os.environ["LOCUST_USERS"] = "100"
|
130
|
-
os.environ["LOCUST_SPAWN_RATE"] = "10"
|
131
|
-
os.environ["LOCUST_RUN_TIME"] = "5m"
|
132
|
-
os.environ["LOCUST_RESET_STATS"] = "true"
|
133
|
-
os.environ["LOCUST_STOP_TIMEOUT"] = "5"
|
134
|
-
os.environ["LOCUST_USER_CLASSES"] = "MyUserClass"
|
135
|
-
options = parse_options(args=[])
|
136
|
-
|
137
|
-
self.assertEqual("locustfile.py", options.locustfile)
|
138
|
-
self.assertEqual(100, options.num_users)
|
139
|
-
self.assertEqual(10, options.spawn_rate)
|
140
|
-
self.assertEqual("5m", options.run_time)
|
141
|
-
self.assertTrue(options.reset_stats)
|
142
|
-
self.assertEqual("5", options.stop_timeout)
|
143
|
-
self.assertEqual(["MyUserClass"], options.user_classes)
|
144
|
-
# check default arg
|
145
|
-
self.assertEqual(8089, options.web_port)
|
146
|
-
|
147
|
-
del os.environ["LOCUST_LOCUSTFILE"]
|
148
|
-
del os.environ["LOCUST_USERS"]
|
149
|
-
del os.environ["LOCUST_SPAWN_RATE"]
|
150
|
-
del os.environ["LOCUST_RUN_TIME"]
|
151
|
-
del os.environ["LOCUST_RESET_STATS"]
|
152
|
-
del os.environ["LOCUST_STOP_TIMEOUT"]
|
153
|
-
del os.environ["LOCUST_USER_CLASSES"]
|
154
|
-
|
155
|
-
def test_parse_locustfile(self):
|
156
|
-
with mock_locustfile() as mocked:
|
157
|
-
locustfiles = parse_locustfile_option(
|
158
|
-
args=[
|
159
|
-
"-f",
|
160
|
-
mocked.file_path,
|
161
|
-
"-u",
|
162
|
-
"100",
|
163
|
-
"-r",
|
164
|
-
"10",
|
165
|
-
"-t",
|
166
|
-
"5m",
|
167
|
-
"--reset-stats",
|
168
|
-
"--stop-timeout",
|
169
|
-
"5",
|
170
|
-
"MyUserClass",
|
171
|
-
]
|
172
|
-
)
|
173
|
-
locustfile = locustfiles[0]
|
174
|
-
self.assertEqual(mocked.file_path, locustfile)
|
175
|
-
assert len(locustfiles) == 1
|
176
|
-
locustfiles = parse_locustfile_option(
|
177
|
-
args=[
|
178
|
-
"-f",
|
179
|
-
mocked.file_path,
|
180
|
-
]
|
181
|
-
)
|
182
|
-
locustfile = locustfiles[0]
|
183
|
-
self.assertEqual(mocked.file_path, locustfile)
|
184
|
-
assert len(locustfiles) == 1
|
185
|
-
|
186
|
-
def test_parse_locustfile_multiple_files(self):
|
187
|
-
with mock_locustfile() as mocked1:
|
188
|
-
with mock_locustfile(dir=self.parent_dir.name) as mocked2:
|
189
|
-
locustfiles = parse_locustfile_option(
|
190
|
-
args=[
|
191
|
-
"-f",
|
192
|
-
f"{mocked1.file_path},{mocked2.file_path}",
|
193
|
-
]
|
194
|
-
)
|
195
|
-
|
196
|
-
self.assertIn(mocked1.file_path, locustfiles)
|
197
|
-
self.assertIn(mocked2.file_path, locustfiles)
|
198
|
-
assert 2 == len(locustfiles)
|
199
|
-
|
200
|
-
def test_parse_locustfile_with_directory(self):
|
201
|
-
with mock_locustfile(dir=self.parent_dir.name) as mocked:
|
202
|
-
locustfiles = parse_locustfile_option(
|
203
|
-
args=[
|
204
|
-
"-f",
|
205
|
-
self.parent_dir.name,
|
206
|
-
]
|
207
|
-
)
|
208
|
-
|
209
|
-
self.assertIn(mocked.file_path, locustfiles)
|
210
|
-
|
211
|
-
def test_parse_locustfile_with_nested_directory(self):
|
212
|
-
"""
|
213
|
-
Mock Directory contents:
|
214
|
-
|
215
|
-
├── parent_dir/
|
216
|
-
│ ├── mock_locustfile1.py
|
217
|
-
│ └── child_dir/
|
218
|
-
│ ├── mock_locustfile2.py
|
219
|
-
│ ├── mock_locustfile3.py
|
220
|
-
"""
|
221
|
-
with mock_locustfile(filename_prefix="mock_locustfile1", dir=self.parent_dir.name) as mock_locustfile1:
|
222
|
-
with mock_locustfile(filename_prefix="mock_locustfile2", dir=self.child_dir.name) as mock_locustfile2:
|
223
|
-
with mock_locustfile(filename_prefix="mock_locustfile3", dir=self.child_dir.name) as mock_locustfile3:
|
224
|
-
locustfiles = parse_locustfile_option(
|
225
|
-
args=[
|
226
|
-
"-f",
|
227
|
-
self.parent_dir.name,
|
228
|
-
]
|
229
|
-
)
|
230
|
-
|
231
|
-
self.assertIn(mock_locustfile1.file_path, locustfiles)
|
232
|
-
self.assertIn(mock_locustfile2.file_path, locustfiles)
|
233
|
-
self.assertIn(mock_locustfile3.file_path, locustfiles)
|
234
|
-
|
235
|
-
def test_parse_locustfile_with_directory_ignores_invalid_filenames(self):
|
236
|
-
with NamedTemporaryFile(suffix=".py", prefix="_", dir=self.parent_dir.name) as invalid_file1:
|
237
|
-
with NamedTemporaryFile(suffix=".txt", prefix="", dir=self.parent_dir.name) as invalid_file2:
|
238
|
-
with mock_locustfile(filename_prefix="mock_locustfile1", dir=self.parent_dir.name) as mock_locustfile1:
|
239
|
-
locustfiles = parse_locustfile_option(
|
240
|
-
args=[
|
241
|
-
"-f",
|
242
|
-
self.parent_dir.name,
|
243
|
-
]
|
244
|
-
)
|
245
|
-
|
246
|
-
self.assertIn(mock_locustfile1.file_path, locustfiles)
|
247
|
-
self.assertNotIn(invalid_file1.name, locustfiles)
|
248
|
-
self.assertNotIn(invalid_file2.name, locustfiles)
|
249
|
-
|
250
|
-
def test_parse_locustfile_empty_directory_error(self):
|
251
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
252
|
-
with self.assertRaises(SystemExit):
|
253
|
-
parse_locustfile_option(
|
254
|
-
args=[
|
255
|
-
"-f",
|
256
|
-
self.parent_dir.name,
|
257
|
-
]
|
258
|
-
)
|
259
|
-
|
260
|
-
def test_parse_locustfile_and_directory(self):
|
261
|
-
with mock_locustfile(filename_prefix="mock_locustfile1", dir=self.parent_dir.name) as mock_locustfile1:
|
262
|
-
with mock_locustfile(filename_prefix="mock_locustfile2", dir=self.parent_dir.name) as mock_locustfile2:
|
263
|
-
with mock_locustfile(filename_prefix="mock_locustfile3", dir=self.child_dir.name) as mock_locustfile3:
|
264
|
-
locustfiles = parse_locustfile_option(
|
265
|
-
args=[
|
266
|
-
"-f",
|
267
|
-
f"{mock_locustfile1.file_path},{self.child_dir.name}",
|
268
|
-
]
|
269
|
-
)
|
270
|
-
self.assertIn(mock_locustfile1.file_path, locustfiles)
|
271
|
-
self.assertNotIn(mock_locustfile2.file_path, locustfiles)
|
272
|
-
self.assertIn(mock_locustfile3.file_path, locustfiles)
|
273
|
-
|
274
|
-
def test_parse_multiple_directories(self):
|
275
|
-
with mock_locustfile(filename_prefix="mock_locustfile1", dir=self.child_dir.name) as mock_locustfile1:
|
276
|
-
with mock_locustfile(filename_prefix="mock_locustfile2", dir=self.child_dir2.name) as mock_locustfile2:
|
277
|
-
locustfiles = parse_locustfile_option(
|
278
|
-
args=[
|
279
|
-
"-f",
|
280
|
-
f"{self.child_dir.name},{self.child_dir2.name}",
|
281
|
-
]
|
282
|
-
)
|
283
|
-
|
284
|
-
self.assertIn(mock_locustfile1.file_path, locustfiles)
|
285
|
-
self.assertIn(mock_locustfile2.file_path, locustfiles)
|
286
|
-
|
287
|
-
def test_parse_locustfile_invalid_directory_error(self):
|
288
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
289
|
-
with self.assertRaises(SystemExit):
|
290
|
-
parse_locustfile_option(
|
291
|
-
args=[
|
292
|
-
"-f",
|
293
|
-
"non_existent_dir",
|
294
|
-
]
|
295
|
-
)
|
296
|
-
|
297
|
-
def test_unknown_command_line_arg(self):
|
298
|
-
with self.assertRaises(SystemExit):
|
299
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
300
|
-
parse_options(
|
301
|
-
args=[
|
302
|
-
"-f",
|
303
|
-
"something.py",
|
304
|
-
"-u",
|
305
|
-
"100",
|
306
|
-
"-r",
|
307
|
-
"10",
|
308
|
-
"-t",
|
309
|
-
"5m",
|
310
|
-
"--reset-stats",
|
311
|
-
"--stop-timeout",
|
312
|
-
"5",
|
313
|
-
"--unknown-flag",
|
314
|
-
"MyUserClass",
|
315
|
-
]
|
316
|
-
)
|
317
|
-
|
318
|
-
def test_custom_argument(self):
|
319
|
-
@locust.events.init_command_line_parser.add_listener
|
320
|
-
def _(parser, **kw):
|
321
|
-
parser.add_argument("--custom-bool-arg", action="store_true", help="Custom boolean flag")
|
322
|
-
parser.add_argument(
|
323
|
-
"--custom-string-arg",
|
324
|
-
help="Custom string arg",
|
325
|
-
)
|
326
|
-
|
327
|
-
options = parse_options(
|
328
|
-
args=[
|
329
|
-
"-u",
|
330
|
-
"666",
|
331
|
-
"--custom-bool-arg",
|
332
|
-
"--custom-string-arg",
|
333
|
-
"HEJ",
|
334
|
-
]
|
335
|
-
)
|
336
|
-
self.assertEqual(666, options.num_users)
|
337
|
-
self.assertEqual("HEJ", options.custom_string_arg)
|
338
|
-
self.assertTrue(options.custom_bool_arg)
|
339
|
-
|
340
|
-
def test_custom_argument_help_message(self):
|
341
|
-
@locust.events.init_command_line_parser.add_listener
|
342
|
-
def _(parser, **kw):
|
343
|
-
parser.add_argument("--custom-bool-arg", action="store_true", help="Custom boolean flag")
|
344
|
-
parser.add_argument(
|
345
|
-
"--custom-string-arg",
|
346
|
-
help="Custom string arg",
|
347
|
-
)
|
348
|
-
|
349
|
-
out = StringIO()
|
350
|
-
with mock.patch("sys.stdout", new=out):
|
351
|
-
with self.assertRaises(SystemExit):
|
352
|
-
parse_options(args=["--help"])
|
353
|
-
|
354
|
-
out.seek(0)
|
355
|
-
stdout = out.read()
|
356
|
-
self.assertIn("Custom boolean flag", stdout)
|
357
|
-
self.assertIn("Custom string arg", stdout)
|
358
|
-
|
359
|
-
def test_csv_full_history_requires_csv(self):
|
360
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
361
|
-
with self.assertRaises(SystemExit):
|
362
|
-
parse_options(
|
363
|
-
args=[
|
364
|
-
"-f",
|
365
|
-
"locustfile.py",
|
366
|
-
"--csv-full-history",
|
367
|
-
]
|
368
|
-
)
|
369
|
-
|
370
|
-
def test_custom_argument_included_in_web_ui(self):
|
371
|
-
@locust.events.init_command_line_parser.add_listener
|
372
|
-
def _(parser, **kw):
|
373
|
-
parser.add_argument("--a1", help="a1 help")
|
374
|
-
parser.add_argument("--a2", help="a2 help", include_in_web_ui=False)
|
375
|
-
parser.add_argument("--a3", help="a3 help", is_secret=True)
|
376
|
-
|
377
|
-
args = ["-u", "666", "--a1", "v1", "--a2", "v2", "--a3", "v3"]
|
378
|
-
options = parse_options(args=args)
|
379
|
-
self.assertEqual(666, options.num_users)
|
380
|
-
self.assertEqual("v1", options.a1)
|
381
|
-
self.assertEqual("v2", options.a2)
|
382
|
-
|
383
|
-
extra_args = ui_extra_args_dict(args)
|
384
|
-
self.assertIn("a1", extra_args)
|
385
|
-
self.assertNotIn("a2", extra_args)
|
386
|
-
self.assertIn("a3", extra_args)
|
387
|
-
self.assertEqual("v1", extra_args["a1"]["default_value"])
|
388
|
-
|
389
|
-
|
390
|
-
class TestFindLocustfiles(LocustTestCase):
|
391
|
-
def setUp(self):
|
392
|
-
super().setUp()
|
393
|
-
self.parent_dir1 = TemporaryDirectory()
|
394
|
-
self.parent_dir2 = TemporaryDirectory()
|
395
|
-
self.child_dir = TemporaryDirectory(dir=self.parent_dir1.name)
|
396
|
-
|
397
|
-
def tearDown(self):
|
398
|
-
super().tearDown()
|
399
|
-
self.child_dir.cleanup()
|
400
|
-
self.parent_dir1.cleanup()
|
401
|
-
self.parent_dir2.cleanup()
|
402
|
-
|
403
|
-
def test_find_locustfiles_with_is_directory(self):
|
404
|
-
with mock_locustfile(dir=self.parent_dir1.name) as mocked1:
|
405
|
-
with mock_locustfile(dir=self.child_dir.name) as mocked2:
|
406
|
-
with mock_locustfile(dir=self.child_dir.name) as mocked3:
|
407
|
-
locustfiles = parse_locustfile_paths([self.parent_dir1.name])
|
408
|
-
|
409
|
-
self.assertIn(mocked1.file_path, locustfiles)
|
410
|
-
self.assertIn(mocked2.file_path, locustfiles)
|
411
|
-
self.assertIn(mocked3.file_path, locustfiles)
|
412
|
-
assert 3 == len(locustfiles)
|
413
|
-
|
414
|
-
def test_find_locustfiles_error_if_directory_doesnt_exist(self):
|
415
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
416
|
-
with self.assertRaises(SystemExit):
|
417
|
-
parse_locustfile_paths(["some_directory"])
|
418
|
-
|
419
|
-
def test_find_locustfiles_ignores_invalid_files_in_directory(self):
|
420
|
-
with NamedTemporaryFile(suffix=".py", prefix="_", dir=self.parent_dir1.name) as invalid_file1:
|
421
|
-
with NamedTemporaryFile(suffix=".txt", prefix="", dir=self.parent_dir1.name) as invalid_file2:
|
422
|
-
with mock_locustfile(filename_prefix="mock_locustfile1", dir=self.parent_dir1.name) as mock_locustfile1:
|
423
|
-
locustfiles = parse_locustfile_paths([self.parent_dir1.name])
|
424
|
-
|
425
|
-
self.assertIn(mock_locustfile1.file_path, locustfiles)
|
426
|
-
self.assertNotIn(invalid_file1.name, locustfiles)
|
427
|
-
self.assertNotIn(invalid_file2.name, locustfiles)
|
428
|
-
assert 1 == len(locustfiles)
|
429
|
-
|
430
|
-
def test_find_locustfiles_with_multiple_locustfiles(self):
|
431
|
-
with mock_locustfile() as mocked1:
|
432
|
-
with mock_locustfile() as mocked2:
|
433
|
-
locustfiles = parse_locustfile_paths([mocked1.file_path, mocked2.file_path])
|
434
|
-
|
435
|
-
self.assertIn(mocked1.file_path, locustfiles)
|
436
|
-
self.assertIn(mocked2.file_path, locustfiles)
|
437
|
-
|
438
|
-
assert 2 == len(locustfiles)
|
439
|
-
|
440
|
-
def test_find_locustfiles_error_for_invalid_file_extension(self):
|
441
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
442
|
-
with mock_locustfile() as valid_file:
|
443
|
-
with self.assertRaises(SystemExit):
|
444
|
-
invalid_file = NamedTemporaryFile(suffix=".txt")
|
445
|
-
parse_locustfile_paths([valid_file.file_path, invalid_file.name])
|
446
|
-
|
447
|
-
def test_find_locustfiles_error_if_multiple_values_for_directory(self):
|
448
|
-
with mock.patch("sys.stderr", new=StringIO()):
|
449
|
-
with self.assertRaises(SystemExit):
|
450
|
-
parse_locustfile_paths([self.parent_dir1.name, self.parent_dir2.name])
|