#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: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:

Merge pull request #1234 from tahoe-lafs/3947.mutable-test_version-async-def

Convert some tests for mutables to use async def

Fixes: ticket:3947

Note: See TracTickets for help on using tickets.