def test_runStopAfterTests(self):
        """
        L{DistTrialRunner} calls C{reactor.stop} and unlocks the test directory
        once the tests have run.
        """
        class CountingReactorWithSuccess(CountingReactor):

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

            def succeedingRun(self, case, result):
                return succeed(None)

        workingDirectory = self.runner._workingDirectory

        workers = []
        fakeReactor = CountingReactorWithSuccess(workers)

        self.runner.run(TestCase(), fakeReactor)

        def check():
            localLock = FilesystemLock(workingDirectory + ".lock")
            self.assertTrue(localLock.lock())
            self.assertEqual(1, fakeReactor.stopCount)

        self.assertEqual(list(fakeReactor.triggers.keys()), ["before"])
        self.assertEqual(list(fakeReactor.triggers["before"]), ["shutdown"])
        self.reap(workers)

        return deferLater(reactor, 0, check)

        L{DistTrialRunner} calls C{reactor.stop} and unlocks the test directory
        once the tests have run.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/_dist/test/test_disttrial.py