我有卡桑德拉集群的代码
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>)
我得到这个是因为这两个对象是不同的,有没有办法在mock中检查called_with
相关问题 更多 >
编程相关推荐