ioloop_test.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 
00004 from __future__ import absolute_import, division, with_statement
00005 import datetime
00006 import unittest
00007 import time
00008 
00009 from tornado.testing import AsyncTestCase, LogTrapTestCase
00010 
00011 
00012 class TestIOLoop(AsyncTestCase, LogTrapTestCase):
00013     def test_add_callback_wakeup(self):
00014         # Make sure that add_callback from inside a running IOLoop
00015         # wakes up the IOLoop immediately instead of waiting for a timeout.
00016         def callback():
00017             self.called = True
00018             self.stop()
00019 
00020         def schedule_callback():
00021             self.called = False
00022             self.io_loop.add_callback(callback)
00023             # Store away the time so we can check if we woke up immediately
00024             self.start_time = time.time()
00025         self.io_loop.add_timeout(time.time(), schedule_callback)
00026         self.wait()
00027         self.assertAlmostEqual(time.time(), self.start_time, places=2)
00028         self.assertTrue(self.called)
00029 
00030     def test_add_timeout_timedelta(self):
00031         self.io_loop.add_timeout(datetime.timedelta(microseconds=1), self.stop)
00032         self.wait()
00033 
00034 if __name__ == "__main__":
00035     unittest.main()


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Thu Jan 2 2014 11:53:55