#9010 enhancement closed duplicate (duplicate)

successResultOf and failureResultOf should handle coroutines

Reported by: Wilfredo Sánchez Vega Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

twisted.trial.unittest.SynchronousTestCase.successResultOf takes a deferred argument, which should be a Deferred object.

If given a coroutine, that should also work:

class SomeTests(unittest.SynchronousTestCase):
    async def someAsyncFunction():
        return 5

    def test_someAsyncFunctionReturnsFive(self):
        result = self.successResultOf(someAsyncFunction())
        self.assertEqual(result, 5)

Same for twisted.trial.unittest.SynchronousTestCase.failureResultOf.

Change History (3)

comment:1 Changed 11 months ago by Wilfredo Sánchez Vega

Adding deferred = ensureDeferred(deferred) to the top of each of these does the trick.

comment:2 Changed 11 months ago by Wilfredo Sánchez Vega

Oops I already filed #9006.

comment:3 Changed 11 months ago by Wilfredo Sánchez Vega

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.