'Invoking python -m twisted should execute twist.'

def test_twisted(self):

    cmd = sys.executable
    p = Accumulator()
    d = p.endedDeferred = defer.Deferred()
    reactor.spawnProcess(p, cmd, [cmd, '-m', 'twisted', '--help'], env=None)
    p.transport.closeStdin()
    from twisted import __main__
    self.patch(sys, 'argv', [__main__.__file__, '--help'])
    def processEnded(ign):
        f = p.outF
        output = f.getvalue().replace('\r\n', '\n')
        options = TwistOptions()
        message = '{}\n'.format(options).encode('utf-8')
        self.assertEqual(output, message)
    return d.addCallback(processEnded)
