我有像cassandra cluster这样的代码
cluster = Cluster(
config.CASS_CLUSTER,
load_balancing_policy=policies.DCAwareRoundRobinPolicy(
config.CASS_D_CENTER))
当我为此编写UT并尝试Cluster
使用我的参数检查调用时。
mock_cluster.assert_called_with(
config.CASS_CLUSTER,
load_balancing_policy=policies.DCAwareRoundRobinPolicy(
config.CASS_D_CENTER))
它给出了错误。
AssertionError: Expected call: Cluster(['192.168.1.1'], load_balancing_policy=<cassandra.policies.DCAwareRoundRobinPolicy object at 0x106fa2ed0>)
Actual call: Cluster(['192.168.1.1'], load_balancing_policy=<cassandra.policies.DCAwareRoundRobinPolicy object at 0x106fa2cd0>)
我得到这个是因为两个对象都不同,是否有任何方法可以检查called_with
模拟?
mock_cluster.assert_called_with(
config.CASS_CLUSTER,
load_balancing_policy=mock.ANY)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句