cfa75f07803cb2067083899196f293f87176504f
HTTPretty
Version 0.1
What
HTTPretty is a HTTP client mock library for Python 100% inspired on ruby's FakeWeb
Motivation
When building systems that access external resources such as RESTful webservices, XMLRPC or even simple HTTP requests, we stumble in the problem:
"I'm gonna need to mock all those requests"
It brings a lot of hassle, you will need to use a generic mocking tool, mess with scope and so on.
The idea behind HTTPretty (how it works)
HTTPretty monkey matches Python's socket core module, reimplementing the HTTP protocol, by mocking requests and responses.
This is a nice thing, if you consider that all python http modules are supposed to get mocked.
Usage
from httpretty import HTTPretty
HTTPretty.register_uri(HTTPretty.GET, "http://globo.com/",
body="The biggest portal in Brazil")
fd = urllib2.urlopen('http://globo.com')
got = fd.read()
fd.close()
print got
:: output ::
The biggest portal in Brazil
Dependencies
you will need ONLY if you decide to contribute to HTTPretty which means you're gonna need run our test suite
Here is a oneliner
I know you want it :)
sudo pip install multiprocessing sure nose tornado httplib2 bolacha
Contributing
- fork and clone the project
- install the dependencies above
- run the tests with make:
make unit functional
- hack at will
- commit, push etc
- send a pull request
License
<HTTPretty - HTTP client mock for Python>
Copyright (C) <2011> Gabriel Falcão <gabriel@nacaolivre.org>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Description
Languages
Python
86.6%
JavaScript
6.3%
HTML
3.9%
CSS
2%
Makefile
0.9%
Other
0.3%