unit testing - Nosetests assert_equal apparently not equal to python == -
i'm programming temperature control setup has different sources (in example one):
source = source() sources_dict = { key: source } temp_control = tempcontrol(args) #a dictionary built on instantiation based on args #and assigned temp_control.sources
sources_dict defined same args of tempcontrol(args). see content of loop works , not.
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 not, following error message:
assertionerror: <pvd_temp_control.source object @ 0x02aa63b0> != <pvd_temp_cont rol.source object @ 0x02aa6330> -------------------- >> begin captured stdout << --------------------- sources_dict: {'cu': <pvd_temp_control.source object @ 0x02aa6330>} tempcontrol.sources: {'cu': <pvd_temp_control.source object @ 0x02aa63b0>} source: <pvd_temp_control.source object @ 0x02aa6330> --------------------- >> end captured stdout << ----------------------
any ideas why?
i had more specific. assert_equal won't magic , go through dictionary. correct example:
for key, value in tempcontrol.sources.iteritems(): assert_equal(value.element_name, sources_dict[key].key_name)
Comments
Post a Comment