mitogen/tests/utils_test.py

33 lines
737 B
Python
Raw Normal View History

2016-08-26 19:10:25 +00:00
#!/usr/bin/env python
import unittest
2017-09-16 07:15:25 +00:00
import mitogen.master
import mitogen.utils
2016-08-26 19:10:25 +00:00
def func0(router):
return router
2016-08-26 19:10:25 +00:00
@mitogen.utils.with_router
def func(router):
return router
2016-08-26 19:10:25 +00:00
class RunWithRouterTest(unittest.TestCase):
2016-08-26 19:10:25 +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())
2016-08-26 19:10:25 +00:00
class WithRouterTest(unittest.TestCase):
2016-08-26 19:10:25 +00:00
def test_with_broker(self):
router = func()
self.assertTrue(isinstance(router, mitogen.master.Router))
self.assertFalse(router.broker._thread.isAlive())