Skip to content

Commit 2f16a25

Browse files
authored
Flatten test_threadpool_threadrange_set
It had param-dependent logic in the test which usually leads to mistakes over time. This patch makes the test body simple.
1 parent e6ae44b commit 2f16a25

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

cheroot/test/test_server.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -444,21 +444,26 @@ def many_open_sockets(request, resource_limit):
444444

445445

446446
@pytest.mark.parametrize(
447-
('minthreads', 'maxthreads'),
447+
('minthreads', 'maxthreads', 'inited_maxthreads'),
448448
(
449-
(1, -2), # the docstring only mentions -1 to mean "no max", but other
450-
# negative numbers should also work
451-
(1, -1),
452-
(1, 1),
453-
(1, 2),
454-
(1, float('inf')),
455-
(2, -2),
456-
(2, -1),
457-
(2, 2),
458-
(2, float('inf')),
449+
(
450+
# NOTE: The docstring only mentions -1 to mean "no max", but other
451+
# NOTE: negative numbers should also work.
452+
1,
453+
-2,
454+
float('inf'),
455+
),
456+
(1, -1, float('inf')),
457+
(1, 1, 1),
458+
(1, 2, 2),
459+
(1, float('inf'), float('inf')),
460+
(2, -2, float('inf')),
461+
(2, -1, float('inf')),
462+
(2, 2, 2),
463+
(2, float('inf'), float('inf')),
459464
),
460465
)
461-
def test_threadpool_threadrange_set(minthreads, maxthreads):
466+
def test_threadpool_threadrange_set(minthreads, maxthreads, inited_maxthreads):
462467
"""Test setting the number of threads in a ThreadPool.
463468
464469
The ThreadPool should properly set the min+max number of the threads to use
@@ -470,10 +475,7 @@ def test_threadpool_threadrange_set(minthreads, maxthreads):
470475
max=maxthreads,
471476
)
472477
assert tp.min == minthreads
473-
if maxthreads < 0:
474-
assert tp.max == float('inf')
475-
else:
476-
assert tp.max == maxthreads
478+
assert tp.max == inited_maxthreads
477479

478480

479481
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)