mitogen/tests/utils_test.py

37 lines
787 B
Python
Raw Normal View History

2017-09-15 06:24:41 +00:00
#!/usr/bin/env python
import unittest2 as unittest
2017-09-15 06:24:41 +00:00
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.assertIsInstance(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.assertIsInstance(router, mitogen.master.Router)
self.assertFalse(router.broker._thread.isAlive())
2017-10-02 09:06:36 +00:00
if __name__ == '__main__':
unittest.main()