[英]Nosetests assert_equal apparently not equal to python ==
I'm programming the temperature control for a setup that has different sources (in this example only one): 我正在为具有不同来源的设置编程温度控制(在此示例中只有一个):
source = Source()
sources_dict = {
key: source
}
temp_control = TempControl(args) #A dictionary is built on instantiation based on args
#and assigned to temp_control.sources
sources_dict is defined with the same args of TempControl(args). 使用与TempControl(args)相同的args定义sources_dict。 See the content of the for loop for what works and does not. 请参阅for循环的内容,以了解哪些有效,哪些无效。
for key, value in tempControl.sources.iteritems():
assert_equal(value, sources_dict[key]) #Fails
tempControl.sources[key] == sources_dict[key] #Works
value == sources_dict[key] #Works
When it does not, I get the following error message: 如果没有,我会收到以下错误消息:
AssertionError: <pvd_temp_control.Source object at 0x02AA63B0> != <pvd_temp_cont
rol.Source object at 0x02AA6330>
-------------------- >> begin captured stdout << ---------------------
sources_dict: {'Cu': <pvd_temp_control.Source object at 0x02AA6330>}
tempControl.sources: {'Cu': <pvd_temp_control.Source object at 0x02AA63B0>}
source: <pvd_temp_control.Source object at 0x02AA6330>
--------------------- >> end captured stdout << ----------------------
Any ideas why? 有什么想法吗?
I had to be more specific. 我必须更具体。 assert_equal won't do magic and go through the dictionary. assert_equal不会做魔术并且要去字典。 This is correct for example: 例如,这是正确的:
for key, value in tempControl.sources.iteritems():
assert_equal(value.element_name, sources_dict[key].key_name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.