mitogen/tests/utils_test.py

33 lines
723 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(broker):
return broker
2017-09-16 07:15:25 +00:00
@mitogen.utils.with_broker
2016-08-26 19:10:25 +00:00
def func(broker):
return broker
class RunWithBrokerTest(unittest.TestCase):
# test_shutdown_on_exception
# test_shutdown_on_success
def test_run_with_broker(self):
2017-09-16 07:15:25 +00:00
broker = mitogen.utils.run_with_broker(func0)
self.assertTrue(isinstance(broker, mitogen.master.Broker))
2016-08-26 19:10:25 +00:00
self.assertFalse(broker._thread.isAlive())
class WithBrokerTest(unittest.TestCase):
def test_with_broker(self):
broker = func()
2017-09-16 07:15:25 +00:00
self.assertTrue(isinstance(broker, mitogen.master.Broker))
2016-08-26 19:10:25 +00:00
self.assertFalse(broker._thread.isAlive())