'Test running a process: check its output, it exitCode, some property of
signalProcess.'

def test_process(self):

    scriptPath = 'twisted.test.process_tester'
    d = defer.Deferred()
    p = TestProcessProtocol()
    p.deferred = d
    reactor.spawnProcess(p, pyExe, [pyExe, '-u', '-m', scriptPath], env=properEnv)
    def check(ignored):
        self.assertEqual(p.stages, [1, 2, 3, 4, 5])
        f = p.reason
        f.trap(error.ProcessTerminated)
        self.assertEqual(f.value.exitCode, 23)
        self.assertRaises(error.ProcessExitedAlready, p.transport.signalProcess, 'INT')
        try:
            import process_tester, glob
            for f in glob.glob(process_tester.test_file_match):
                os.remove(f)
        except:
            pass
    d.addCallback(check)
    return d
