'L{AdoptedStreamServerEndpoint.listen} closes its file descriptor after
adding it to the reactor with L{IReactorSocket.adoptStreamPort}.'

def test_descriptorClosed(self):

    reactor = MemoryReactor()
    endpoint = self._createStubbedAdoptedEndpoint(reactor, 13, AF_INET)
    events = []
    def close(fileno):
        events.append(('close', fileno, len(reactor.adoptedPorts)))
    endpoint._close = close
    d = endpoint.listen(object())
    def listened(ignored):
        self.assertEqual([('close', 13, 1)], events)
    d.addCallback(listened)
    return d
