Bye bye httpretty. Welcome back good old mock!

19 March 2015   4 comments   Python

After a day of pushing 9 commits to a PR to finally get Travis to build a simple python package on python 2.6, 2.7, 3.3 and 3.4 I finally gave up and ripped out all of httpretty and replaced it with good old mock.patch()

I was getting all sorts of strange warnings in py3.3 and 3.4 got stuck all the time.
This is not the first time httpretty has been causing confusion so from now on I'm giving up on httpretty. Ithink it was too good to be true to work reliably. Honestly, it might be python's fault for not being better made available to cool libs like httpretty.

By the way, here's one of those errors where Python 3.4 just hangs which stopped being the case once I took out httpretty. And here you can see the clear failure to deactivate the monkeypatch even after the test is complete in Python 3.3.

Comments

Brian Curtin
httpretty has been breaking a lot of OpenStack projects lately with those releases that hang on 3.4. I just removed it entirely from my project and I think others are doing the same. Using mock directly is great and mostly what we switched to, but there were also a few cases where httpretty's idea was what we wanted, so requests-mock took its place: http://www.jamielennox.net/blog/2014/08/26/requests-mock/
mindflayer
Have a look at the module we presented at EuroPython 2013, it does support Py2/Py3 since the beginning, and it's also a platform to build mocks for everything that run on sockets.
https://github.com/mocketize/python-mocket
Peter Bengtsson
Cool! I'll check it out when time allows.
Anonymous
Hi Peter, I was having a look at the traffic summary on the mocket GitHub page and it pointed me to this post.
Did you have the chance to try the library? If so, what do you think about it?

Your email will never ever be published


Related posts

Previous:
How to slice a rune in Go 16 March 2015
Next:
Autocompeter.com 02 April 2015
Related by Keyword:
Mocking DBRefs in Mongoose and nodeunit 14 April 2011
Mocking os.stat in Python 08 November 2009
Mocking a Python standard library 14 March 2008
Related by Text:
jQuery and Highslide JS 08 January 2008
I'm back! Peterbe.com has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
Ever wondered how much $87 Billion is? 04 November 2003
Guake, not Yakuake or Yeahconsole 23 January 2010