def test_timedOutProvidedCancelSuccess(self):
        """
        If a cancellation function is provided when the L{defer.Deferred} is
        initialized, the L{defer.Deferred} returns the cancellation value's
        non-failure return value when the L{defer.Deferred} times out.
        """
        clock = Clock()
        d = defer.Deferred(lambda c: c.callback('I was cancelled!'))
        d.addTimeout(10, clock)
        self.assertNoResult(d)

        clock.advance(15)

        self.assertEqual(self.successResultOf(d), 'I was cancelled!')

        If a cancellation function is provided when the L{defer.Deferred} is
        initialized, the L{defer.Deferred} returns the cancellation value's
        non-failure return value when the L{defer.Deferred} times out.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_defer.py