Mock pathc question

Jean-Michel Pichavant jeanmichel at sequans.com
Thu Aug 8 06:04:38 EDT 2013


----- 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.


More information about the Python-list mailing list