A few more improvements were made to Mocker.
-
Recent Posts
Categories
Archives
- August 2016
- June 2016
- April 2016
- February 2016
- October 2015
- May 2015
- January 2015
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- April 2014
- March 2014
- February 2014
- December 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- August 2012
- June 2012
- April 2012
- January 2012
- December 2011
- November 2011
- October 2011
- August 2011
- July 2011
- December 2010
- November 2010
- September 2010
- July 2010
- June 2010
- May 2010
- March 2010
- December 2009
- November 2009
- October 2009
- August 2009
- July 2009
- June 2009
- May 2009
- August 2008
- June 2008
- May 2008
- March 2008
- February 2008
- December 2007
- November 2007
- October 2007
- August 2007
- June 2007
- May 2007
- March 2007
- November 2006
- August 2006
- July 2006
- February 2006
- October 2005
- September 2005
- July 2005
- June 2005
- May 2005
- April 2005
- March 2005
- December 2004
- June 2004
- March 2004
- February 2004
- December 2003
- October 2003
- June 2003
Meta
Hey there. Very impressed with mocker, it’s great to work with, although I initially thought there was an issue with it due to it’s behaviour under iPython:
In [1]: from mocker import Mocker
In [2]: mocker = Mocker()
In [3]: mock = mocker.mock()
In [4]: mock.test1()
Out[4]:
In [5]: mocker.result(‘test1’)
In [6]: mocker.replay()
In [7]: mock.test1()
Out[7]:
This behaves correctly under the bare interpreter, although it also outputs the “<mocker.Mock object …” line (is this correct? it’s not shown in the docs…). Any ideas on how I can get mocker running properly under iPython?
Thanks for an incredibly handy module!
Sorry, the output lines got eaten, they’re both displaying repr output that reads: “mocker.Mock object at 0xb78e058c”
cheers
The problem here is that IPython performs some basic inspection in the mock object, which ends up recording an action. I’ll release a new version of Mocker which fixes this problem.
Thanks for reporting it.
Awesome, thank you!
I’ve been using PyMock a lot, and I’m very happy to see that Mocker addresses a lot of my complaints about PyMock, not the least of which is documentation—thanks for the clear examples in the tutorial!
There appears to be an error in the first example in the tutorial, though. Instead of “mock.restore()” and “mock.verify()”, I believe it should be “mocker.restore()” and “mocker.verify()” since the mock objects themselves seem to be upset about receiving unexpected expressions if you try to call these methods on them instead of on the Mocker instance.
Cheers!
Oops.. it was incorrect indeed. I’ve fixed that, and have also renamed all “mock” instances in the documentation to “obj”, reducing a bit the volume of “mock” prefixes and thus the confusion.
Thanks for reporting this.