def test_asFutureCancelFuture(self):
        """
        L{defer.Deferred.asFuture} returns a L{asyncio.Future} which, when
        cancelled, will cancel the original L{defer.Deferred}.
        """
        def canceler(dprime):
            canceler.called = True
        canceler.called = False
        d = defer.Deferred(canceler)
        loop = new_event_loop()
        aFuture = d.asFuture(loop)
        aFuture.cancel()
        callAllSoonCalls(loop)
        self.assertEqual(canceler.called, True)
        self.assertEqual(self.successResultOf(d), None)
        self.assertRaises(CancelledError, aFuture.result)

        L{defer.Deferred.asFuture} returns a L{asyncio.Future} which, when
        cancelled, will cancel the original L{defer.Deferred}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_defer.py