Skip to content

Commit

Permalink
chore: updated dependencies, fixed watchdog test for ExceptionGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas committed Apr 10, 2024
1 parent ccef2ac commit 16d894e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ exceptiongroup = "^1.2.0"
[tool.poetry.group.dev.dependencies]
pytest = "^8.1.0"
pytest-trio = ">=0.8.0"
pytest-cov = "^4.1.0"
coverage = { extras = ["toml"], version = "^7.2.7" }
pytest-cov = "^5.0.0"
coverage = { extras = ["toml"], version = "^7.4.0" }

[[tool.poetry.source]]
name = "PyPI"
Expand Down Expand Up @@ -47,5 +47,5 @@ lint.ignore = ["B905", "C901", "E402", "E501"]
lint.select = ["B", "C", "E", "F", "W"]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
16 changes: 12 additions & 4 deletions test/test_watchdog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pytest import raises
from contextlib import contextmanager

from trio import current_time, open_nursery, sleep, TooSlowError
from trio.testing import RaisesGroup, Matcher

from flockwave.concurrency import use_watchdog
from flockwave.concurrency.watchdog import Watchdog
Expand All @@ -12,16 +14,22 @@ async def test_watchdog_normal_operation(autojump_clock):
watchdog.notify()


@contextmanager
def watchdog_expires():
with RaisesGroup(Matcher(TooSlowError, match="watchdog expired")):
yield


async def test_watchdog_expiry(autojump_clock):
with raises(TooSlowError, match="watchdog expired"):
with watchdog_expires():
async with use_watchdog(timeout=1) as watchdog:
for i in range(10):
await sleep(i * 0.4)
watchdog.notify()


async def test_watchdog_never_notified(autojump_clock):
with raises(TooSlowError, match="watchdog expired"):
with watchdog_expires():
async with use_watchdog(timeout=1):
for i in range(10):
await sleep(i * 0.4)
Expand All @@ -37,7 +45,7 @@ async def test_sync_start(autojump_clock):


async def test_sync_start_expiry(autojump_clock):
with raises(TooSlowError, match="watchdog expired"):
with watchdog_expires():
async with open_nursery() as nursery:
with Watchdog(timeout=1).use_soon(nursery) as watchdog:
for i in range(10):
Expand Down

0 comments on commit 16d894e

Please sign in to comment.