def setUp(self):
        """
        Override some things in mailmail, so that we capture C{stdout},
        and do not call L{reactor.stop}.
        """
        self.out = NativeStringIO()
        # Override the mailmail logger, so we capture stderr output
        from twisted.logger import textFileLogObserver, Logger
        logObserver = textFileLogObserver(self.out)
        self.patch(mailmail, '_log', Logger(observer=logObserver))
        self.host = None
        self.options = None
        self.ident = None

        # Override mailmail.sendmail, so we don't call reactor.stop()
        def sendmail(host, options, ident):
            self.host = host
            self.options = options
            self.ident = ident
            return smtp.sendmail(host, options.sender, options.to,
                                 options.body, reactor=self.memoryReactor)

        self.patch(mailmail, 'sendmail', sendmail)

        Override some things in mailmail, so that we capture C{stdout},
        and do not call L{reactor.stop}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_mailmail.py