def test_stopServiceWhileConnecting(self):
        """
        When the service is stopped while initially connecting, the connection
        attempt is cancelled.
        """
        clock = Clock()
        cq, service = self.makeReconnector(fireImmediately=False, clock=clock)
        self.assertEqual(len(cq.connectQueue), 1)
        self.assertNoResult(cq.connectQueue[0])
        d = service.stopService()
        self.successResultOf(d)

        When the service is stopped while initially connecting, the connection
        attempt is cancelled.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/application/test/test_internet.py