'C{reactor.stop()} fires all three phases of shutdown event triggers
before it makes C{reactor.run()} return.'

def test_stopShutDownEvents(self):

    reactor = self.buildReactor()
    events = []
    reactor.addSystemEventTrigger('before', 'shutdown', (lambda : events.append(('before', 'shutdown'))))
    reactor.addSystemEventTrigger('during', 'shutdown', (lambda : events.append(('during', 'shutdown'))))
    reactor.addSystemEventTrigger('after', 'shutdown', (lambda : events.append(('after', 'shutdown'))))
    reactor.callWhenRunning(reactor.stop)
    self.runReactor(reactor)
    self.assertEqual(events, [('before', 'shutdown'), ('during', 'shutdown'), ('after', 'shutdown')])
