def test_processExitedRaises(self):
        """
        If L{IProcessProtocol.processExited} raises an exception, it is logged.
        """
        # Ideally we wouldn't need to poke the process module; see
        # https://twistedmatrix.com/trac/ticket/6889
        reactor = self.buildReactor()

        class TestException(Exception):
            pass

        class Protocol(ProcessProtocol):
            def processExited(self, reason):
                reactor.stop()
                raise TestException("processedExited raised")

        protocol = Protocol()
        transport = reactor.spawnProcess(
               protocol, pyExe, [pyExe, b"-c", b""],
               usePTY=self.usePTY)
        self.runReactor(reactor)

        # Manually clean-up broken process handler.
        # Only required if the test fails on systems that support
        # the process module.
        if process is not None:
            for pid, handler in items(process.reapProcessHandlers):
                if handler is not transport:
                    continue
                process.unregisterReapProcessHandler(pid, handler)
                self.fail("After processExited raised, transport was left in"
                          " reapProcessHandlers")

        self.assertEqual(1, len(self.flushLoggedErrors(TestException)))

        If L{IProcessProtocol.processExited} raises an exception, it is logged.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_process.py