def test_failureBeforeTimeoutCustom(self):
        """
        The L{defer.Deferred} errbacks with the failure if it fails before the
        timeout, even if using a custom C{onTimeoutCancel} function.
        No cancellation happens after the errback either, which could also
        cancel inner deferreds.
        """
        clock = Clock()
        d = defer.Deferred()
        d.addTimeout(10, clock, onTimeoutCancel=_overrideFunc)

        # addTimeout is added first so that if d is timed out, d would be
        # canceled before innerDeferred gets returned from an errback on d
        innerDeferred = defer.Deferred()
        dErrbacked = [None]
        error = ValueError("fail")

        def onErrback(f):
            dErrbacked[0] = f
            return innerDeferred

        d.addErrback(onErrback)
        d.errback(error)

        # d is errbacked immediately, before innerDeferred is returned from the
        # errback on d
        self.assertIsInstance(dErrbacked[0], failure.Failure)
        self.assertIs(dErrbacked[0].value, error)

        # The timeout never happens - if it did, d would have been cancelled,
        # which would cancel innerDeferred too
        clock.advance(15)
        self.assertNoResult(innerDeferred)

        The L{defer.Deferred} errbacks with the failure if it fails before the
        timeout, even if using a custom C{onTimeoutCancel} function.
        No cancellation happens after the errback either, which could also
        cancel inner deferreds.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_defer.py