flask-httpretty help you to mock http requests via flask.
Project description
# Flask-httpretty
[![Build Status](https://travis-ci.org/admire93/flask-httpretty.svg?branch=master)](https://travis-ci.org/admire93/flask-httpretty)
Mock http request with flask!
flask-httpretty is built based on [httpretty][hp].
## Hello world
from flask import Flask
from urllib.request import urlopen
import flask_httpretty
app = Flask(__name__)
@app.route('/', methods=['GET'])
def hello_world():
return 'hello world'
@flask_httpretty.activate
def test_hello_world():
flask_httpretty.register_app(app, 'http://hellotest.com')
resp = urlopen('http://hellotest.com').read()
assert 'hello world' == resp.decode('utf-8')
## Officially supported libraries
Since flask-httpretty use [httpretty][hp] to monkey patches pythons'socket,
it support same libraries [httpretty do][hp-support]. these are
* [requests](http://docs.python-requests.org/en/latest/)
* [httplib2](http://code.google.com/p/httplib2/)
* [urllib](https://docs.python.org/3.4/library/urllib.request.html)
[hp]: https://github.com/gabrielfalcao/HTTPretty
[hp-support]: https://github.com/gabrielfalcao/HTTPretty#officially-supported-libraries
[![Build Status](https://travis-ci.org/admire93/flask-httpretty.svg?branch=master)](https://travis-ci.org/admire93/flask-httpretty)
Mock http request with flask!
flask-httpretty is built based on [httpretty][hp].
## Hello world
from flask import Flask
from urllib.request import urlopen
import flask_httpretty
app = Flask(__name__)
@app.route('/', methods=['GET'])
def hello_world():
return 'hello world'
@flask_httpretty.activate
def test_hello_world():
flask_httpretty.register_app(app, 'http://hellotest.com')
resp = urlopen('http://hellotest.com').read()
assert 'hello world' == resp.decode('utf-8')
## Officially supported libraries
Since flask-httpretty use [httpretty][hp] to monkey patches pythons'socket,
it support same libraries [httpretty do][hp-support]. these are
* [requests](http://docs.python-requests.org/en/latest/)
* [httplib2](http://code.google.com/p/httplib2/)
* [urllib](https://docs.python.org/3.4/library/urllib.request.html)
[hp]: https://github.com/gabrielfalcao/HTTPretty
[hp-support]: https://github.com/gabrielfalcao/HTTPretty#officially-supported-libraries
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-httpretty-1.2.0.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file Flask-httpretty-1.2.0.tar.gz
.
File metadata
- Download URL: Flask-httpretty-1.2.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bc96a578bf1d0cb3f0dbf61ca33622cc56c87f2ef396bd2ecf5cf1667b864dc |
|
MD5 | eb9107fc2fb17dd47daa4d383953923e |
|
BLAKE2b-256 | 3e187f3c5949f2a19520e40cb5ab2201c4167a2fdf3c5607c1deec35f2bcbb38 |
File details
Details for the file Flask_httpretty-1.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: Flask_httpretty-1.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 090a1ed2d97c528b179951f551194acaaf485399fcc554ad761fa59c11640b6d |
|
MD5 | b3b36ec0e44c23e0391900d8168aa287 |
|
BLAKE2b-256 | 7d47ebe76d109790ea84471fd1ab875b8ee381e82d579b91249b4211513da515 |