テストメソッドからDoSomething()メソッドを呼び出すと、Connect()のyieldでブロックされると期待していますが、そうではなく、まだ呼び出されていない遅延を返します。
Class Foo:
@defer.inlineCallbacks
def Connect(self):
amqpConfig = AmqpConfig(self.config.getConfigFile())
self.amqp = AmqpFactory(amqpConfig)
try:
# First Deferred
d = self.amqp.connect()
# Second Deferred
d.addCallback(lambda ign: self.amqp.getChannelReadyDeferred())
# Block until connecting and getting an AMQP channel
yield d
except Exception, e:
self.log.error('Cannot connect to AMQP broker: %s', e)
def DoSomething(self):
c = self.Connect()
# None of the deferreds were fired, c.called is False
2番目(そして最後)の延期が呼び出されるまでブロックさせるにはどうすればよいですか?