def test_register_twice_does_not_duplicate_fd(self, select):
     poller = SelectPoller()
     select.select.return_value = (poller._fds, None, None)
     poller.register(0)
     poller.register(0)
     fd = poller.poll()
     self.assertEqual(fd, [0])
 def test_register_twice_does_not_duplicate_fd(self, select):
     poller = SelectPoller()
     select.select.return_value = (poller._fds, None, None)
     poller.register(0)
     poller.register(0)
     fd = poller.poll()
     self.assertEqual(fd, [0])
 def test_unregister_twice_has_no_side_effect(self):
     poller = SelectPoller()
     poller.register(0)
     poller.unregister(0)
     try:
         poller.unregister(0)
     except Exception as ex:
         self.fail("Shouldn't have failed: %s" % ex)
 def test_unregister_twice_has_no_side_effect(self):
     poller = SelectPoller()
     poller.register(0)
     poller.unregister(0)
     try:
         poller.unregister(0)
     except Exception as ex:
         self.fail("Shouldn't have failed: %s" % ex)
    def test_release_poller(self, select):
        poller = SelectPoller()
        select.select.return_value = (poller._fds, None, None)

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

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

        poller.release()
        fd = poller.poll()
        self.assertEqual(fd, [])
    def test_release_poller(self, select):
        poller = SelectPoller()
        select.select.return_value = (poller._fds, None, None)
        
        poller.register(0)
        poller.register(1)
        fd = poller.poll()
        self.assertEqual(fd, [0, 1])

        poller.unregister(0)
        fd = poller.poll()
        self.assertEqual(fd, [1])
        
        poller.release()
        fd = poller.poll()
        self.assertEqual(fd, [])
 def test_register_twice_does_not_duplicate_fd(self):
     poller = SelectPoller()
     poller.register(0)
     poller.register(0)
     fd = poller.poll()
     self.assertEqual(fd, [0])