Пример #1
0
        poller.register_readable(6)
        poller.poll(1)
        self.assertEqual(options.logger.data[0], 'EBADF encountered in poll')
        self.assertEqual(list(poller.readables), [])
        self.assertEqual(list(poller.writables), [])

    def test_poll_uncaught_exception(self):
        _select = DummySelect(error=errno.EPERM)
        options = DummyOptions()
        poller = self._makeOne(options)
        poller._select = _select
        poller.register_readable(6)
        self.assertRaises(select.error, poller.poll, 1)


if implements_kqueue():
    KQueuePollerTestsBase = unittest.TestCase
else:
    KQueuePollerTestsBase = SkipTestCase


class KQueuePollerTests(KQueuePollerTestsBase):

    def _makeOne(self, options):
        return KQueuePoller(options)

    def test_register_readable(self):
        kqueue = DummyKQueue()
        poller = self._makeOne(DummyOptions())
        poller._kqueue = kqueue
        poller.register_readable(6)
Пример #2
0
        poller.register_readable(6)
        poller.poll(1)
        self.assertEqual(options.logger.data[0], 'EBADF encountered in poll')
        self.assertEqual(list(poller.readables), [])
        self.assertEqual(list(poller.writables), [])

    def test_poll_uncaught_exception(self):
        _select = DummySelect(error=errno.EPERM)
        options = DummyOptions()
        poller = self._makeOne(options)
        poller._select = _select
        poller.register_readable(6)
        self.assertRaises(select.error, poller.poll, 1)


if implements_kqueue():
    KQueuePollerTestsBase = unittest.TestCase
else:
    KQueuePollerTestsBase = SkipTestCase


class KQueuePollerTests(KQueuePollerTestsBase):
    def _makeOne(self, options):
        return KQueuePoller(options)

    def test_register_readable(self):
        kqueue = DummyKQueue()
        poller = self._makeOne(DummyOptions())
        poller._kqueue = kqueue
        poller.register_readable(6)
        self.assertEqual(list(poller.readables), [6])