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


Groups > comp.lang.python > #52183

Re: Mock pathc question

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=9258f6e39=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.154
X-Spam-Level *
X-Spam-Evidence '*H*': 0.69; '*S*': 0.00; 'classes,': 0.05; 'decorator': 0.09; 'subject:question': 0.10; 'cc:addr:python- list': 0.11; 'belongs': 0.16; 'module': 0.19; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'possibly': 0.26; 'post': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'patch': 0.29; 'code': 0.31; 'object.': 0.31; 'file': 0.32; 'class': 0.32; '-----': 0.33; 'add': 0.35; 'thanks': 0.36; 'should': 0.36; 'list': 0.37; 'thank': 0.38; 'skip:m 40': 0.38; 'how': 0.40; "you're": 0.61; 'you.': 0.62; 'information': 0.63; 'name': 0.63; 'refer': 0.63; 'skip:n 10': 0.64; 'received:194': 0.64; 'different': 0.65; 'iphone': 0.65; 'to:addr:gmail.com': 0.65; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.89,838,1367964000"; d="scan'208";a="1770432"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Thu, 8 Aug 2013 12:04:38 +0200 (CEST)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Avishay Balderman <balderman@gmail.com>
In-Reply-To <-8538360675205673045@unknownmsgid>
Subject Re: Mock pathc question
MIME-Version 1.0
X-Mailer Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC28 (Win)/7.2.4_GA_2900)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.344.1375956285.1251.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375956285 news.xs4all.nl 15912 [2001:888:2000:d::a6]:52588
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52183

Show key headers only | 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