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.
33 lines
729 B
Python
33 lines
729 B
Python
8 years ago
|
#!/usr/bin/env python
|
||
|
|
||
|
import unittest
|
||
|
|
||
|
import econtext.master
|
||
|
import econtext.utils
|
||
|
|
||
|
|
||
|
def func0(broker):
|
||
|
return broker
|
||
|
|
||
|
|
||
|
@econtext.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 = econtext.utils.run_with_broker(func0)
|
||
|
self.assertTrue(isinstance(broker, econtext.master.Broker))
|
||
|
self.assertFalse(broker._thread.isAlive())
|
||
|
|
||
|
|
||
|
class WithBrokerTest(unittest.TestCase):
|
||
|
def test_with_broker(self):
|
||
|
broker = func()
|
||
|
self.assertTrue(isinstance(broker, econtext.master.Broker))
|
||
|
self.assertFalse(broker._thread.isAlive())
|