jeudi 4 juin 2015

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). See the content of the for loop for what works and does 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 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?

Aucun commentaire:

Enregistrer un commentaire