Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52206

Re: Mock pathc question

Newsgroups comp.lang.python
Date 2013-08-08 09:15 -0700
References <-8538360675205673045@unknownmsgid> <mailman.344.1375956285.1251.python-list@python.org>
Message-ID <aad7d032-5a08-4bb7-a3c4-93555afec0df@googlegroups.com> (permalink)
Subject Re: Mock pathc question
From balderman@gmail.com

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Mock pathc question Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-08-08 12:04 +0200
  Re: Mock pathc question balderman@gmail.com - 2013-08-08 09:15 -0700

csiph-web