

Show HN: HTTPretty, an easy way to mock http requests in python - gfalcao
http://falcao.it/HTTPretty/

======
leftnode
I'm just getting start with Python and was using the Requests library this
morning. I didn't like that my tests were coupled to both the library and an
Internet connection existing.

This just hits the frontpage today and it is exactly what I'm looking for.
Thank you!

~~~
gfalcao
Thanks great, I'm glad you found it useful

------
zer01
Hot damn, this makes testing easy. Thanks a lot for the module! There's a
small typo in your page. "HTTPretty monkey matches" should be "HTTPretty
monkey patches".

Great job though!

~~~
gfalcao
thanks zer01, I just fixed that.

------
kevin1024
I'm working on a HTTP testing library based on Ruby's VCR library[1]. I've got
it to a pretty basic state where it is somewhat usable. I'm definitely
interested in this area. Ruby's VCR uses the Webmock library as a backend
(though it can use other pluggable backends) to mock out all the HTTP
requests. I had to sort of grow my own Webmock - maybe I can integrate
HTTPretty instead so we don't duplicate effort.

[1]: <http://www.github.com/kevin1024/vcrpy/>

~~~
gingerlime
Nice. The thing I liked about VCR is that it not only allows you to mock HTTP
responses, but actually records the real response the first time you use it.
So you don't even necessarily have to specify what the contents/headers of the
response should look like manually... To have an equivalent library for python
would be very neat. Hope you guys can join effort somehow to make it happen.

------
xvolter
Oh wow, this could turn out to be very useful. Can use this for automated
testing for public APIs.

~~~
cyphrd
I think we'll put this to use right away.

------
bryanh
Wonderful, was considering writing this just the other day. Thank you good
sir.

One thing that would be _really_ nice, is a record mode and serialization (to
JSON/yaml/etc...) plus a context manager (python's with). How ready are you
for pull requests? ;-)

~~~
gfalcao
bryanh, just saw your pull request, I'm excited to get your contributions :)

~~~
bryanh
I haven't done one yet! Must be someone else. Regardless, I just wanted to
make sure you guys weren't planning on lots of refactoring if I sank a bunch
of time into it.

------
emillon
Fantastic, I tried to roll my own a few times but never got to this point.
Thanks !

~~~
gfalcao
Please feel free to send pull-requests. There are some cool features to be
done; supporting wildcards and/or regexes is one of them

------
maak
Very useful. Thank-you.

------
denzil_correa
Great! I always used to have a fixed set of functions written in my personal
code base todo these things. Glad yo know you have made a generic library.
Good job.

