'Reactor names are listed alphabetically by I{--help-reactors}.'

def test_sortedReactorHelp(self):

    class FakeReactorInstaller(object, ):
        def __init__(self, name):
            self.shortName = ('name    of    ' + name)
            self.description = ('description    of    ' + name)
            self.moduleName = 'twisted.internet.default'
    apple = FakeReactorInstaller('apple')
    banana = FakeReactorInstaller('banana')
    coconut = FakeReactorInstaller('coconut')
    donut = FakeReactorInstaller('donut')
    def getReactorTypes():
        (yield coconut)
        (yield banana)
        (yield donut)
        (yield apple)
    config = twistd.ServerOptions()
    self.assertEqual(config._getReactorTypes, reactors.getReactorTypes)
    config._getReactorTypes = getReactorTypes
    config.messageOutput = NativeStringIO()
    self.assertRaises(SystemExit, config.parseOptions, ['--help-reactors'])
    helpOutput = config.messageOutput.getvalue()
    indexes = []
    for reactor in (apple, banana, coconut, donut):
        def getIndex(s):
            self.assertIn(s, helpOutput)
            indexes.append(helpOutput.index(s))
        getIndex(reactor.shortName)
        getIndex(reactor.description)
    self.assertEqual(indexes, sorted(indexes), ('reactor    descriptions    were    not    in    alphabetical    order:    %r' % (helpOutput,)))
