Skip to content

Fix asyncio warnings in test suite#227

Merged
thomwiggers merged 1 commit intodevelopfrom
onebot-fixtests
Feb 18, 2026
Merged

Fix asyncio warnings in test suite#227
thomwiggers merged 1 commit intodevelopfrom
onebot-fixtests

Conversation

@thomwiggers
Copy link
Copy Markdown
Owner

@thomwiggers thomwiggers commented Feb 17, 2026

Summary

Replaces irc3.testing.IrcBot and irc3.testing.BotTestCase with our own versions that properly manage asyncio event loops, fixing all 9 asyncio-related test warnings.

Changes to onebot/testing.py

IrcBot (now inherits from irc3.IrcBot directly instead of irc3.testing.IrcBot):

  • Closes the temporary event loop created for create_autospec (irc3 leaks it)
  • check_required() is a no-op (avoids creating ~/.irc3/ during tests)
  • Defaults asynchronous=False when a real loop is provided, preventing irc3 from spawning a process_queue coroutine that is never cleaned up
  • Re-exports patch from unittest.mock (used by plugin doctests)

BotTestCase:

  • Uses our IrcBot instead of irc3.testing.IrcBot
  • Registers addCleanup handler that cancels pending asyncio tasks and closes real event loops after each test

Changes to tests

  • test_onebot.py: Pass asynchronous=False to OneBot and close the event loop in tearDown
  • test_plugin_acl.py: Remove redundant manual loop.close() (now handled by base class)

Test plan

  • All 71 tests pass with 0 warnings
  • Verify no behavior change in test assertions

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

🤖 Hi @thomwiggers, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions
Copy link
Copy Markdown

🤖 I'm sorry @thomwiggers, but I was unable to process your request. Please see the logs for more details.

@thomwiggers thomwiggers force-pushed the onebot-fixtests branch 3 times, most recently from a52d6d2 to 225a956 Compare February 17, 2026 16:23
Bypass irc3.testing.IrcBot which leaks temporary event loops (creates
asyncio.new_event_loop() just for autospec, then discards without closing).
Our IrcBot now inherits from irc3.IrcBot directly, closing the temp loop.

Add addCleanup-based loop teardown in BotTestCase.callFTU() that cancels
pending tasks and closes real event loops after each test. Set
asynchronous=False by default for test bots to avoid unnecessary
process_queue coroutines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@thomwiggers thomwiggers merged commit ac1d9ce into develop Feb 18, 2026
17 checks passed
@thomwiggers thomwiggers deleted the onebot-fixtests branch February 18, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant