Example #1
0
class TestAsyncEvent(tornado.testing.AsyncTestCase):

    def setUp(self):
        super(TestAsyncEvent, self).setUp()
        self._event = AsyncEvent(self.io_loop)

    @tornado.testing.gen_test
    def test_timeout_of_until_set(self):
        @tornado.gen.coroutine
        def call_set():
            self._event.set()
        # Test for timing out
        with self.assertRaises(tornado.gen.TimeoutError):
            yield self._event.until_set(timeout=0.1)
        # Test for NOT timing out
        self.io_loop.add_callback(call_set)
        yield self._event.until_set(timeout=0.1)
Example #2
0
class TestAsyncEvent(tornado.testing.AsyncTestCase):
    def setUp(self):
        super(TestAsyncEvent, self).setUp()
        self._event = AsyncEvent(self.io_loop)

    @tornado.testing.gen_test
    def test_timeout_of_until_set(self):
        @tornado.gen.coroutine
        def call_set():
            self._event.set()

        # Test for timing out
        with self.assertRaises(tornado.gen.TimeoutError):
            yield self._event.until_set(timeout=0.1)
        # Test for NOT timing out
        self.io_loop.add_callback(call_set)
        yield self._event.until_set(timeout=0.1)