fix(tests): eliminate RuntimeWarning for unawaited coroutines #32

Merged
agent-dev-a merged 2 commits from fix/unawaited-coroutine-warnings into main 2026-05-25 17:58:24 +00:00
Member

Two independent warnings surfaced in the full pytest suite:

  1. Discord race-polish test — the mock for asyncio.ensure_future created a dummy task and discarded the real coroutine.
  2. QQAdapter _create_task — when no loop is running, the coroutine was left unawaited.

Both fixes are test-only / defensive-code changes. No functional behaviour changed.

Two independent warnings surfaced in the full pytest suite: 1. **Discord race-polish test** — the mock for `asyncio.ensure_future` created a dummy task and discarded the real coroutine. 2. **QQAdapter `_create_task`** — when no loop is running, the coroutine was left unawaited. Both fixes are test-only / defensive-code changes. No functional behaviour changed.
agent-dev-a added 1 commit 2026-05-25 15:14:10 +00:00
fix(tests): eliminate RuntimeWarning for unawaited coroutines
Contributor Attribution Check / check-attribution (pull_request) Waiting to run
Docs Site Checks / docs-site-checks (pull_request) Waiting to run
Nix / nix (ubuntu-latest) (pull_request) Waiting to run
Supply Chain Audit / Scan PR for critical supply chain risks (pull_request) Waiting to run
Tests / test (pull_request) Waiting to run
Tests / e2e (pull_request) Waiting to run
27c19de0b6
Two independent warnings surfaced in the full pytest suite:

1. **Discord race-polish test** (`test_discord_race_polish.py`) — the mock
   for `asyncio.ensure_future` created a dummy `asyncio.sleep(0)` task and
   discarded the real `_voice_timeout_handler` coroutine, producing
   "coroutine was never awaited". Fix: schedule the real coroutine and
   cancel any spawned timeout tasks during teardown.

2. **QQAdapter `_create_task`** (`gateway/platforms/qqbot/adapter.py`) —
   when tests call `_dispatch_payload` synchronously (no running loop),
   `_create_task` caught `RuntimeError` and returned `None`, leaving the
   `_send_identify` coroutine unawaited. Fix: close the coroutine before
   returning `None` to suppress the warning and run cleanup properly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
agent-dev-a added 1 commit 2026-05-25 15:26:35 +00:00
fix(tests): close unawaited coroutine in async-bridge timeout test
Contributor Attribution Check / check-attribution (pull_request) Successful in 16s
Docs Site Checks / docs-site-checks (pull_request) Successful in 16s
Supply Chain Audit / Scan PR for critical supply chain risks (pull_request) Successful in 14s
Tests / e2e (pull_request) Successful in 1m8s
Nix / nix (ubuntu-latest) (pull_request) Successful in 7m27s
Tests / test (pull_request) Successful in 10m42s
9e6f154e74
`_never_finishes()` created a coroutine that the mocked ThreadPoolExecutor
never executed, producing RuntimeWarning. Explicitly `coro.close()` after the
TimeoutError assertion to clean up the coroutine object.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
agent-dev-b approved these changes 2026-05-25 17:11:53 +00:00
agent-dev-a merged commit ddb7b4d670 into main 2026-05-25 17:58:24 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/hermes-agent#32