'L{IReactorCore.fireSystemEvent} should behave the same way for a
particular system event regardless of whether Deferreds are being
waited on for a different system event.'

def test_interactionBetweenDifferentEvents(self):

    events = []
    firstEvent = 'first-event'
    firstDeferred = Deferred()
    def beforeFirstEvent():
        events.append(('before', 'first'))
        return firstDeferred
    def afterFirstEvent():
        events.append(('after', 'first'))
    secondEvent = 'second-event'
    secondDeferred = Deferred()
    def beforeSecondEvent():
        events.append(('before', 'second'))
        return secondDeferred
    def afterSecondEvent():
        events.append(('after', 'second'))
    self.addTrigger('before', firstEvent, beforeFirstEvent)
    self.addTrigger('after', firstEvent, afterFirstEvent)
    self.addTrigger('before', secondEvent, beforeSecondEvent)
    self.addTrigger('after', secondEvent, afterSecondEvent)
    self.assertEqual(events, [])
    reactor.fireSystemEvent(firstEvent)
    self.assertEqual(events, [('before', 'first')])
    reactor.fireSystemEvent(secondEvent)
    self.assertEqual(events, [('before', 'first'), ('before', 'second')])
    firstDeferred.callback(None)
    self.assertEqual(events, [('before', 'first'), ('before', 'second'), ('after', 'first')])
    secondDeferred.callback(None)
    self.assertEqual(events, [('before', 'first'), ('before', 'second'), ('after', 'first'), ('after', 'second')])
