mitogen/tests/utils_test.py

37 lines
786 B
Python
Raw Normal View History

2017-09-15 06:24:41 +00:00
#!/usr/bin/env python
import unittest
import mitogen.master
import mitogen.utils
def func0(router):
return router
2017-09-15 06:24:41 +00:00
@mitogen.utils.with_router
def func(router):
return router
2017-09-15 06:24:41 +00:00
class RunWithRouterTest(unittest.TestCase):
2017-09-15 06:24:41 +00:00
# test_shutdown_on_exception
# test_shutdown_on_success
def test_run_with_broker(self):
router = mitogen.utils.run_with_router(func0)
self.assertTrue(isinstance(router, mitogen.master.Router))
self.assertFalse(router.broker._thread.isAlive())
2017-09-15 06:24:41 +00:00
class WithRouterTest(unittest.TestCase):
2017-09-15 06:24:41 +00:00
def test_with_broker(self):
router = func()
self.assertTrue(isinstance(router, mitogen.master.Router))
self.assertFalse(router.broker._thread.isAlive())
2017-10-02 09:06:36 +00:00
if __name__ == '__main__':
unittest.main()