'Test that the platform accept(2) call fails with either L{EMFILE} or
L{ENOBUFS} when there are too many file descriptors open.'

def test_acceptOutOfFiles(self):

    port = self.socket()
    port.bind(('127.0.0.1', 0))
    serverPortNumber = port.getsockname()[1]
    port.listen(5)
    client = self.socket()
    client.setblocking(False)
    for i in range(self.socketLimit):
        try:
            self.socket()
        except socket.error as e:
            if (e.args[0] in (EMFILE, ENOBUFS)):
                break
            else:
                raise
    else:
        self.fail('Could    provoke    neither    EMFILE    nor    ENOBUFS    from    platform.')
    self.assertIn(client.connect_ex(('127.0.0.1', serverPortNumber)), (0, EINPROGRESS))
    exc = self.assertRaises(socket.error, port.accept)
    self.assertIn(exc.args[0], (EMFILE, ENOBUFS))
