#3886 new enhancement

It is inconvenient to test code using `async def` using Tahoe's unittest-based testing tools

Reported by: exarkun Owned by:
Priority: normal Milestone: undecided
Component: dev-infrastructure Version: n/a
Keywords: Cc:
Launchpad Bug:

Description

There are four base classes for test cases in allmydata.test.common - SyncTestCase, AsyncTestCase, AsyncBrokenTestCase, and TrialTestCase.

None of these allow definition of a test using async def with the behavior you would expect (behavior analogous to what you get from AsyncTestCase and a test method returning a Deferred).

As async def becomes the more popular way to define asynchronous functions and pervasive direct use of Deferred becomes less popular, it would probably be nice if it were at least as convenient to test with async def as it is with Deferred-returning functions.

Change History (2)

comment:1 Changed at 2022-04-06T15:27:36Z by itamarst

There's a decorator that enables one solution to this in test_storage_https.py, async_to_defered (once https://github.com/tahoe-lafs/tahoe-lafs/pull/1189 is merged).

comment:2 Changed at 2022-11-30T14:24:25Z by exarkun

It turns out the change in Twisted 22.8 to make maybeDeferred support coroutines makes both trial and testtools work with async def test methods.

Note: See TracTickets for help on using tickets.