def test_runUnexpectedError(self):
        """
        If for some reasons we can't connect to the worker process, the test
        suite catches and fails.
        """

        class CountingReactorWithFail(CountingReactor):

            def spawnProcess(self, worker, *args, **kwargs):
                self._workers.append(worker)
                worker.makeConnection(FakeTransport())
                self.spawnCount += 1
                worker._ampProtocol.run = self.failingRun

            def failingRun(self, case, result):
                return fail(RuntimeError("oops"))

        scheduler, cooperator = self.getFakeSchedulerAndEternalCooperator()

        workers = []
        fakeReactor = CountingReactorWithFail(workers)
        self.addCleanup(self.reap, workers)

        result = self.runner.run(TestCase(), fakeReactor,
                                 cooperator.cooperate)
        self.assertEqual(fakeReactor.runCount, 1)
        self.assertEqual(fakeReactor.spawnCount, 1)
        scheduler.pump()
        self.assertEqual(1, len(result.original.failures))

        If for some reasons we can't connect to the worker process, the test
        suite catches and fails.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/_dist/test/test_disttrial.py