'A file opened with C{openFile} is close when the connection is lost.'

def test_openedFileClosedWithConnection(self):

    d = self.client.openFile('testfile1', (filetransfer.FXF_READ | filetransfer.FXF_WRITE), {})
    self._emptyBuffers()
    oldClose = os.close
    closed = []
    def close(fd):
        closed.append(fd)
        oldClose(fd)
    self.patch(os, 'close', close)
    def _fileOpened(openFile):
        fd = self.server.openFiles[openFile.handle[4:]].fd
        self.serverTransport.loseConnection()
        self.clientTransport.loseConnection()
        self.serverTransport.clearBuffer()
        self.clientTransport.clearBuffer()
        self.assertEqual(self.server.openFiles, {})
        self.assertIn(fd, closed)
    d.addCallback(_fileOpened)
    return d
