core: split out & extend Broker.sync_call()
parent
592d6fc8d3
commit
9ec360c26d
@ -0,0 +1,32 @@
|
||||
|
||||
import threading
|
||||
|
||||
import unittest2
|
||||
|
||||
import testlib
|
||||
|
||||
import mitogen.core
|
||||
|
||||
|
||||
class DeferSyncTest(testlib.TestCase):
|
||||
klass = mitogen.core.Broker
|
||||
|
||||
def test_okay(self):
|
||||
broker = self.klass()
|
||||
try:
|
||||
th = broker.defer_sync(lambda: threading.currentThread())
|
||||
self.assertEquals(th, broker._thread)
|
||||
finally:
|
||||
broker.shutdown()
|
||||
|
||||
def test_exception(self):
|
||||
broker = self.klass()
|
||||
try:
|
||||
self.assertRaises(ValueError,
|
||||
broker.defer_sync, lambda: int('dave'))
|
||||
finally:
|
||||
broker.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
Loading…
Reference in New Issue