Skip to content

Commit 1273b5d

Browse files
authored
Upgrade to pytest 8 (#8482)
1 parent 283a88c commit 1273b5d

8 files changed

+41
-17
lines changed

distributed/client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4924,7 +4924,10 @@ async def _register_scheduler_plugin(
49244924
)
49254925

49264926
def register_scheduler_plugin(
4927-
self, plugin: SchedulerPlugin, name: str | None = None, idempotent: bool = False
4927+
self,
4928+
plugin: SchedulerPlugin,
4929+
name: str | None = None,
4930+
idempotent: bool | None = None,
49284931
):
49294932
"""
49304933
Register a scheduler plugin.

distributed/deploy/tests/test_cluster.py

-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ async def test_repr():
3232
assert res == expected
3333

3434

35-
@gen_test()
36-
async def test_logs_deprecated():
37-
async with Cluster(asynchronous=True) as cluster:
38-
with pytest.warns(FutureWarning, match="get_logs"):
39-
cluster.logs()
40-
41-
4235
@gen_test()
4336
async def test_cluster_wait_for_worker():
4437
async with LocalCluster(n_workers=2, asynchronous=True) as cluster:

distributed/deploy/tests/test_local.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ async def test_threads_per_worker_set_to_0():
10571057
n_workers=2, processes=False, threads_per_worker=0, asynchronous=True
10581058
) as cluster:
10591059
assert len(cluster.workers) == 2
1060-
assert all(w.nthreads < CPU_COUNT for w in cluster.workers.values())
1060+
assert all(w.state.nthreads < CPU_COUNT for w in cluster.workers.values())
10611061

10621062

10631063
@pytest.mark.parametrize("temporary", [True, False])

distributed/deploy/tests/test_spec_cluster.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async def test_spec_process():
269269

270270

271271
@gen_test()
272-
async def test_logs():
272+
async def test_get_logs():
273273
worker = {"cls": Worker, "options": {"nthreads": 1}}
274274
async with SpecCluster(
275275
asynchronous=True, scheduler=scheduler, worker=worker
@@ -304,6 +304,14 @@ async def test_logs():
304304
assert set(logs) == {w}
305305

306306

307+
@gen_test()
308+
async def test_logs_deprecated():
309+
async with SpecCluster(asynchronous=True, scheduler=scheduler) as cluster:
310+
with pytest.warns(FutureWarning, match="get_logs"):
311+
logs = await cluster.logs()
312+
assert logs["Scheduler"]
313+
314+
307315
@gen_test()
308316
async def test_scheduler_info():
309317
async with SpecCluster(

distributed/diagnostics/tests/test_nanny_plugin.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ def teardown(self, nanny):
3535

3636
n_existing_plugins = len(a.plugins)
3737
assert not hasattr(a, "foo")
38-
with pytest.warns(UserWarning, match="`NannyPlugin` as a worker plugin"):
38+
with (
39+
pytest.warns(UserWarning, match="`NannyPlugin` as a worker plugin"),
40+
pytest.warns(DeprecationWarning, match="please use `Client.register_plugin`"),
41+
):
3942
await c.register_worker_plugin(DuckPlugin(), nanny=False)
43+
4044
assert len(a.plugins) == n_existing_plugins + 1
4145
assert a.foo == 123
4246

@@ -52,7 +56,10 @@ def teardown(self, nanny):
5256

5357
n_existing_plugins = len(a.plugins)
5458
assert not hasattr(a, "foo")
55-
with pytest.warns(DeprecationWarning, match="duck-typed.*NannyPlugin"):
59+
with (
60+
pytest.warns(DeprecationWarning, match="duck-typed.*NannyPlugin"),
61+
pytest.warns(DeprecationWarning, match="please use `Client.register_plugin`"),
62+
):
5663
await c.register_worker_plugin(DuckPlugin(), nanny=True)
5764
assert len(a.plugins) == n_existing_plugins + 1
5865
assert a.foo == 123

distributed/diagnostics/tests/test_scheduler_plugin.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,10 @@ def stop(self, scheduler):
603603

604604
n_existing_plugins = len(s.plugins)
605605
assert not hasattr(s, "foo")
606-
with pytest.warns(UserWarning, match="`SchedulerPlugin` as a worker plugin"):
606+
with (
607+
pytest.warns(UserWarning, match="`SchedulerPlugin` as a worker plugin"),
608+
pytest.warns(DeprecationWarning, match="use `Client.register_plugin` instead"),
609+
):
607610
await c.register_worker_plugin(DuckPlugin(), nanny=False)
608611
assert len(s.plugins) == n_existing_plugins + 1
609612
assert s.foo == 123
@@ -620,7 +623,10 @@ def stop(self, scheduler):
620623

621624
n_existing_plugins = len(s.plugins)
622625
assert not hasattr(s, "foo")
623-
with pytest.warns(UserWarning, match="`SchedulerPlugin` as a nanny plugin"):
626+
with (
627+
pytest.warns(UserWarning, match="`SchedulerPlugin` as a nanny plugin"),
628+
pytest.warns(DeprecationWarning, match="use `Client.register_plugin` instead"),
629+
):
624630
await c.register_worker_plugin(DuckPlugin(), nanny=True)
625631
assert len(s.plugins) == n_existing_plugins + 1
626632
assert s.foo == 123

distributed/diagnostics/tests/test_worker_plugin.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ def teardown(self, worker):
299299

300300
n_existing_plugins = len(a.plugins)
301301
assert not hasattr(a, "foo")
302-
with pytest.warns(UserWarning, match="`WorkerPlugin` as a nanny plugin"):
302+
with (
303+
pytest.warns(UserWarning, match="`WorkerPlugin` as a nanny plugin"),
304+
pytest.warns(DeprecationWarning, match="use `Client.register_plugin` instead"),
305+
):
303306
await c.register_worker_plugin(DuckPlugin(), nanny=True)
304307
assert len(a.plugins) == n_existing_plugins + 1
305308
assert a.foo == 123
@@ -316,7 +319,10 @@ def teardown(self, worker):
316319

317320
n_existing_plugins = len(a.plugins)
318321
assert not hasattr(a, "foo")
319-
with pytest.warns(DeprecationWarning, match="duck-typed.*WorkerPlugin"):
322+
with (
323+
pytest.warns(DeprecationWarning, match="duck-typed.*WorkerPlugin"),
324+
pytest.warns(DeprecationWarning, match="use `Client.register_plugin` instead"),
325+
):
320326
await c.register_worker_plugin(DuckPlugin())
321327
assert len(a.plugins) == n_existing_plugins + 1
322328
assert a.foo == 123

distributed/tests/test_semaphore.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ def f(sem_):
219219
while not semaphore_object.metrics["pending"]["t2"]: # Wait for the pending lease
220220
await asyncio.sleep(0.01)
221221
with pytest.warns(
222-
RuntimeWarning, match="Closing semaphore .* but there remain pending leases"
222+
RuntimeWarning,
223+
match=r"Closing semaphore .* but there remain (pending|unreleased) leases",
223224
):
224225
await sem2.close()
225226

0 commit comments

Comments
 (0)