Opened at 2022-11-30T14:28:42Z
Closed at 2022-12-21T10:50:12Z
#3947 closed defect (fixed)
Use `async def` for tests in src/allmydata/test/mutable/test_version.py
Reported by: | exarkun | Owned by: | GitHub <noreply@…> |
---|---|---|---|
Priority: | normal | Milestone: | undecided |
Component: | unknown | Version: | n/a |
Keywords: | Cc: | ||
Launchpad Bug: |
Description
Since Twisted 22.8 we can write async def test methods (with either trial or testtools).
Let's do some of that.
The transformation is basically mechanical.
def test_foo(self): d = some_deferred() d.addCallback(lambda x: some_function(x)) return d
becomes either
async def test_foo(self): x = await some_deferred() some_function(x)
or
async def test_foo(self): x = await some_deferred() await some_function(x)
Deferred.addCallback(f) is happy whether f returns a Deferred or not but await f() only works if f returns an awaitable - thus the choice to make above.
Change History (2)
comment:1 Changed at 2022-11-30T14:35:12Z by exarkun
comment:2 Changed at 2022-12-21T10:50:12Z by GitHub <noreply@…>
- Owner set to GitHub <noreply@…>
- Resolution set to fixed
- Status changed from new to closed
In 80caf04/trunk:
Note: See
TracTickets for help on using
tickets.
https://github.com/tahoe-lafs/tahoe-lafs/pull/1234