Skip to content

Commit 5fda8c9

Browse files
committed
Change the order in which the parameters are applied
1 parent 8c716c5 commit 5fda8c9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

conftest.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,30 @@ def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
281281
filter_regexes = metafunc.config.getoption("filter")
282282
do_shuffle = metafunc.config.getoption("shuffle")
283283
test_cases = util.get_test_cases()
284-
if do_shuffle:
285-
shuffle(test_cases)
286-
if max_num_tests:
287-
test_cases = test_cases[:max_num_tests]
284+
285+
# 1. Apply the filter regexes (if desired):
286+
test_cases = [
287+
test_case
288+
for test_case in test_cases
289+
if all(regex.match(" ".join(test_case)) for regex in filter_regexes)
290+
]
291+
292+
# 2. Apply the selected number of threads:
288293
test_cases = [
289294
(str(num), method, lines, func, term, preciter)
290295
for (
291296
num,
292297
(_old_num, method, lines, func, term, preciter),
293298
) in itertools.product(num_threads_list, test_cases)
294299
]
300+
301+
# 3. Shuffle the tests (if desired):
302+
if do_shuffle:
303+
shuffle(test_cases)
304+
305+
# 4. Apply max. number of tests (if desired):
306+
if max_num_tests:
307+
test_cases = test_cases[:max_num_tests]
308+
295309
test_ids = [" ".join(test_case) for test_case in test_cases]
296-
test_ids = [
297-
test_id
298-
for test_id in test_ids
299-
if all(regex.match(test_id) for regex in filter_regexes)
300-
]
301310
metafunc.parametrize("test_id", test_ids)

0 commit comments

Comments
 (0)