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


Groups > comp.lang.python > #52183

Re: Mock pathc question

Date 2013-08-08 12:04 +0200
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: Mock pathc question
Newsgroups comp.lang.python
Message-ID <mailman.344.1375956285.1251.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext 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