Skip to content

Commit

Permalink
tests: fix no longer supported use of pytest.warns(None) (#849)
Browse files Browse the repository at this point in the history
pytest.warns(None) should be replaced with ensuring no warnings in
another way using the standard lib warnings.
  • Loading branch information
consideRatio authored Jan 20, 2025
1 parent da9f52a commit 1233456
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import time
import warnings

import aiohttp
import dask
Expand Down Expand Up @@ -409,19 +410,17 @@ def test():

def test_cleanup():
# No warnings raised by cleanup function
with pytest.warns(UserWarning) as rec:
with warnings.catch_warnings():
warnings.simplefilter("error", UserWarning)
cleanup_lingering_clusters()
for r in rec:
assert not issubclass(r.category, UserWarning)

# Cluster is now closed
assert cluster.status == "closed"

# No harm in double running
with pytest.warns(UserWarning) as rec:
with warnings.catch_warnings():
warnings.simplefilter("error", UserWarning)
cleanup_lingering_clusters()
for r in rec:
assert not issubclass(r.category, UserWarning)

await loop.run_in_executor(None, test_cleanup)

Expand Down

0 comments on commit 1233456

Please sign in to comment.