Skip to content

Replace asynctest with unittest.IsolatedAsyncioTestCase - #270

Open
rsekman wants to merge 1 commit into
rndusr:masterfrom
rsekman:fix/asynctest
Open

rsekman wants to merge 1 commit into
rndusr:masterfrom
rsekman:fix/asynctest

Conversation

@rsekman

@rsekman rsekman commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

asynctest is abandoned and doesn't work on Python 3.11 and newer, where it fails to import because asyncio.coroutine is gone. That made the whole test suite uncollectable.

Everything asynctest provided is in the standard library now:

  asynctest.TestCase        -> unittest.IsolatedAsyncioTestCase
  asynctest.CoroutineMock   -> unittest.mock.AsyncMock
  asynctest.patch           -> unittest.mock.patch
  async def setUp()         -> async def asyncSetUp()

The exception is ClockedTestCase, which is now in tests/testutils.py. Like asynctest's, its clock starts at 0 and only moves when advance() says so, so tests never wait for real time to pass. advance() steps to each scheduled callback in turn instead of jumping straight to the target time, because a callback that reschedules itself must run once per interval, not once in total.

test_TUI_completion_candidates_for_posargs was skipped because of an asynctest bug and passes now, so it's no longer skipped.

The minimum Python version is now 3.10.

`asynctest` is abandoned and doesn't work on Python 3.11 and newer, where
it fails to import because `asyncio.coroutine` is gone.  That made the
whole test suite uncollectable.

Everything asynctest provided is in the standard library now:
```py
  asynctest.TestCase        -> unittest.IsolatedAsyncioTestCase
  asynctest.CoroutineMock   -> unittest.mock.AsyncMock
  asynctest.patch           -> unittest.mock.patch
  async def setUp()         -> async def asyncSetUp()
```

The exception is `ClockedTestCase`, which is now in `tests/testutils.py`.
Like `asynctest`'s, its clock starts at 0 and only moves when `advance()`
says so, so tests never wait for real time to pass. `advance()` steps to
each scheduled callback in turn instead of jumping straight to the
target time, because a callback that reschedules itself must run once
per interval, not once in total.

`test_TUI_completion_candidates_for_posargs` was skipped because of an
`asynctest` bug and passes now, so it's no longer skipped.

The minimum Python version is now 3.10.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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