我有一个继承自kombu.ConsumerProducerMixin
的类,我想在没有实际运行rabbitmq服务的情况下测试它。
class Aggregator(ConsumerProducerMixin):
def __init__(self, broker_url):
exchange_name = 'chargers'
self.status = 0
self.connection = Connection(broker_url)
...
在我的测试文件中,我执行了以下操作:
^{pr2}$使用调试器进入Aggregator.__init__
,我发现{Mock
实例:
(Pdb) self.connection
<Connection: amqp://guest:**@localhost:5672// at 0x7fc8b7f636d8>
(Pdb) Connection
<class 'kombu.connection.Connection'>
我的问题是如何正确地修补连接,使我不需要rabbitmq来运行测试?
好的,docs声明如下:
因此,解决方案:
相关问题 更多 >
编程相关推荐