def test_callbackAddedToCancelerBeforeTimeout(self):
        """
        Given a deferred with a cancellation function that resumes the
        callback chain, a callback that is added to the deferred
        before a timeout is added to runs when the timeout fires.  The
        deferred completes successfully, without a
        L{defer.TimeoutError}.
        """
        clock = Clock()
        success = "success"
        d = defer.Deferred(lambda d: d.callback(success))

        dCallbacked = [None]

        def callback(value):
            dCallbacked[0] = value
            return value

        d.addCallback(callback)
        d.addTimeout(10, clock)

        clock.advance(15)

        self.assertEqual(dCallbacked[0], success)

        self.assertIs(success, self.successResultOf(d))

        Given a deferred with a cancellation function that resumes the
        callback chain, a callback that is added to the deferred
        before a timeout is added to runs when the timeout fires.  The
        deferred completes successfully, without a
        L{defer.TimeoutError}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_defer.py