Mock pathc question

balderman at gmail.com balderman at gmail.com
Thu Aug 8 12:15:31 EDT 2013


On Thursday, August 8, 2013 12:04:38 PM UTC+2, Jean-Michel Pichavant wrote:
> ----- Mail original ----- 
> 
> > Hi
> > 1) I prefer to use start/stop and not the decorator .
> > 2) mock_play is the name of the module where the code belongs
> 
> > Thanks
> 
> > Avishay
> > Sent from my iPhone
> 
> 
> You should not neeed to refer to the Calc class using mock_play since it is defined in the very same file (module).
> Possibly mock_play.Calc and Calc are 2 different classes, hence you're not patching the good one.
> 
> Note how you patch "mock_play.Calc" and then instanciate using "self.calc = Calc()"
> 
> right before
> my_mock = mock.patch('mock_play.Calc',create=True, new=MockCalc)
> 
> add 
> print mock_play.Calc
> print Calc
> 
> 
> and verify that they are both the very same object.
> 
> Cheers,
> 
> JM
> 
> 
> PS : Please do not top post in this list
> 
> 
> -- IMPORTANT NOTICE: 
> 
> The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Hi
Here is a working solution: http://stackoverflow.com/questions/18121084/mock-patch-does-not-work-properly

thanks



More information about the Python-list mailing list