You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mitogen/tests/utils_test.py

33 lines
723 B
Python

7 years ago
#!/usr/bin/env python
import unittest
import mitogen.master
import mitogen.utils
def func0(broker):
return broker
@mitogen.utils.with_broker
def func(broker):
return broker
class RunWithBrokerTest(unittest.TestCase):
# test_shutdown_on_exception
# test_shutdown_on_success
def test_run_with_broker(self):
broker = mitogen.utils.run_with_broker(func0)
self.assertTrue(isinstance(broker, mitogen.master.Broker))
self.assertFalse(broker._thread.isAlive())
class WithBrokerTest(unittest.TestCase):
def test_with_broker(self):
broker = func()
self.assertTrue(isinstance(broker, mitogen.master.Broker))
self.assertFalse(broker._thread.isAlive())