def test_register_twice_does_not_duplicate_fd(self, select):
     select.epoll.return_value = FakeEpoll()
     poller = EPollPoller()
     poller.register(0)
     poller.register(0)  # IOError is swallowed
     fd = poller.poll()
     self.assertEqual(list(fd), [0])
    def test_release_poller(self, select):
        select.epoll.return_value = FakeEpoll()
        poller = EPollPoller()

        poller.register(0)
        poller.register(1)
        fd = poller.poll()
        self.assertEqual(list(fd), [0, 1])

        poller.unregister(0)
        fd = poller.poll()
        self.assertEqual(list(fd), [1])

        poller.release()
        fd = poller.poll()
        self.assertEqual(list(fd), [])
 def test_register_twice_does_not_duplicate_fd(self, select):
     select.epoll.return_value = FakeEpoll()
     poller = EPollPoller()
     poller.register(0)
     poller.register(0)  # IOError is swallowed
     fd = poller.poll()
     self.assertEqual(list(fd), [0])
    def test_release_poller(self, select):
        select.epoll.return_value = FakeEpoll()
        poller = EPollPoller()
        
        poller.register(0)
        poller.register(1)
        fd = poller.poll()
        self.assertEqual(list(fd), [0, 1])

        poller.unregister(0)
        fd = poller.poll()
        self.assertEqual(list(fd), [1])
        
        poller.release()
        fd = poller.poll()
        self.assertEqual(list(fd), [])
    def test_timeout_when_no_registered_fds(self, select):
        select.epoll.return_value = FakeEpoll()
        poller = EPollPoller(timeout=0.5)
        
        a = time.time()
        fd = list(poller.poll())
        b = time.time()
        self.assertEqual(fd, [])

        d = b - a
        if not (0.48 < d < 0.52):
            self.fail("Did not wait for the appropriate amount of time: %f" % d)
    def test_timeout_when_no_registered_fds(self, select):
        select.epoll.return_value = FakeEpoll()
        poller = EPollPoller(timeout=0.5)

        a = time.time()
        fd = list(poller.poll())
        b = time.time()
        self.assertEqual(fd, [])

        d = b - a
        if not (0.48 < d < 0.52):
            self.fail("Did not wait for the appropriate amount of time: %f" %
                      d)