Skip to content

Commit

Permalink
Handle ruff changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Jan 21, 2025
1 parent 4a81e52 commit 9dcc8b7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/trio/_core/_tests/test_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def example(cause: str) -> AsyncGenerator[int, None]:

async def async_main() -> None:
# GC'ed before exhausted
with pytest.warns(
with pytest.warns( # noqa: PT031
ResourceWarning,
match="Async generator.*collected before.*exhausted",
):
Expand Down
5 changes: 4 additions & 1 deletion src/trio/_core/_tests/test_guest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ async def abandoned_main(in_host: InHost) -> None:
with pytest.raises(ZeroDivisionError):
trivial_guest_run(abandoned_main)

with pytest.warns(RuntimeWarning, match="Trio guest run got abandoned"):
with pytest.warns( # noqa: PT031
RuntimeWarning,
match="Trio guest run got abandoned",
):
do_abandoned_guest_run()
gc_collect_harder()

Expand Down
5 changes: 4 additions & 1 deletion src/trio/_tests/test_deprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ def test_warning_class() -> None:
warn_deprecated("foo", "bar", issue=None, instead=None)

# essentially the same as the above check
with pytest.warns(DeprecationWarning):
with pytest.warns(
DeprecationWarning,
match="^foo is deprecated since Trio bar with no replacement$",
):
warn_deprecated("foo", "bar", issue=None, instead=None)

with pytest.warns(TrioDeprecationWarning):
Expand Down
8 changes: 4 additions & 4 deletions src/trio/_tests/test_dtls.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ async def start_and_forget_endpoint() -> int:
during_tasks = trio.lowlevel.current_statistics().tasks_living
return during_tasks

with pytest.warns(ResourceWarning):
with pytest.warns(ResourceWarning): # noqa: PT031
during_tasks = await start_and_forget_endpoint()
await trio.testing.wait_all_tasks_blocked()
gc_collect_harder()
Expand All @@ -765,7 +765,7 @@ async def start_and_forget_endpoint() -> int:
async def test_gc_before_system_task_starts() -> None:
e = endpoint()

with pytest.warns(ResourceWarning):
with pytest.warns(ResourceWarning): # noqa: PT031
del e
gc_collect_harder()

Expand All @@ -788,7 +788,7 @@ async def test_gc_as_packet_received() -> None:
# At this point, the endpoint's receive loop has been marked runnable because it
# just received a packet; closing the endpoint socket won't interrupt that. But by
# the time it wakes up to process the packet, the endpoint will be gone.
with pytest.warns(ResourceWarning):
with pytest.warns(ResourceWarning): # noqa: PT031
del e
gc_collect_harder()

Expand All @@ -805,7 +805,7 @@ async def main() -> DTLSEndpoint:
return endpoint()

e = trio.run(main)
with pytest.warns(ResourceWarning):
with pytest.warns(ResourceWarning): # noqa: PT031
del e
gc_collect_harder()

Expand Down
4 changes: 2 additions & 2 deletions src/trio/_tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def broken_terminate(self: Process) -> NoReturn:

monkeypatch.setattr(Process, "terminate", broken_terminate)

with pytest.warns(RuntimeWarning, match=".*whoops.*"):
with pytest.warns(RuntimeWarning, match=".*whoops.*"): # noqa: PT031
async with _core.open_nursery() as nursery:
nursery.start_soon(run_process, SLEEP(9999))
await wait_all_tasks_blocked()
Expand All @@ -690,7 +690,7 @@ async def test_warn_on_cancel_SIGKILL_escalation(
) -> None:
monkeypatch.setattr(Process, "terminate", lambda *args: None)

with pytest.warns(RuntimeWarning, match=".*ignored SIGTERM.*"):
with pytest.warns(RuntimeWarning, match=".*ignored SIGTERM.*"): # noqa: PT031
async with _core.open_nursery() as nursery:
nursery.start_soon(run_process, SLEEP(9999))
await wait_all_tasks_blocked()
Expand Down

0 comments on commit 9dcc8b7

Please sign in to comment.