'If C{os.pipe} raises an exception after some pipes where created, the
created pipes are closed and don\'t leak.'

def test_mockErrorInPipe(self):

    pipes = [(-1), (-2), (-3), (-4)]
    def pipe():
        try:
            return (pipes.pop(0), pipes.pop(0))
        except IndexError:
            raise OSError()
    self.mockos.pipe = pipe
    protocol = TrivialProcessProtocol(None)
    self.assertRaises(OSError, reactor.spawnProcess, protocol, None)
    self.assertEqual(self.mockos.actions, [])
    self.assertEqual(set(self.mockos.closed), set([(-4), (-3), (-2), (-1)]))
